简体   繁体   English

如何使用ASPOSE.Cells实例化Office 365 excel文件?

[英]How to instantiate office 365 excel file using ASPOSE.Cells?

When I am trying to create instance of an excel file (.xlsb format) that is generated from office 365 environment it is throwing error. 当我尝试创建从Office 365环境生成的excel文件(.xlsb格式)的实例时,它会抛出错误。

 string fileName = "Subhajit_test.xlsb";
 Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(fileName);

The above code is throwing following error: 上面的代码抛出以下错误:

Invalid workbook setting in the xlsb workbook.
   at .?.??()
   at .?.Read( , ?? )
   at ..Read()
   at ..Read(Workbook , LoadOptions )
   at Aspose.Cells.Workbook.?(Stream , LoadOptions , Boolean )
   at Aspose.Cells.Workbook.?(String , LoadOptions )
   at Aspose.Cells.Workbook..ctor(String file)
   at ASPOSE.GetDataFromExcel..ctor(String fileName)
```[enter image description here][1]


  [1]: https://i.stack.imgur.com/uBBrK.png
//Instantiate a workbook.
Workbook workbook = new Workbook();
//Get the first (default) worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Get the cells in the sheet.
Cells cells = sheet.Cells;
//Merging two cells (B5:C5)into a single cell(B5).
cells.Merge(4,1,1,2);
//Put some value into the merged cell.
cells["B5"].PutValue("Hello World!");
//Align the text as Center aligned.
cells["B5"].Style.HorizontalAlignment = TextAlignmentType.Center;
//Save the file.
workbook.Save("d:\\test\\test_book.xls");

For further ref, please check the different wiki topics for your need: http://www.aspose.com/Wiki/Default.aspx/Aspose.Cells/ 如需进一步参考,请查看不同的wiki主题以满足您的需求: http//www.aspose.com/Wiki/Default.aspx/Aspose.Cells/

I have tried to reproduce the problem with creating an instance of an .xlsb file, and it seems working fine on the latest Aspose.Cells version 19.5. 我试图通过创建.xlsb文件的实例来重现该问题,并且它似乎在最新的Aspose.Cells版本19.5上正常工作。
In v19.2 few issues with saving and opening .xlsb files were fixed, so I would recommend you to upgrade to and try the latest versions. 在v19.2中,保存和打开.xlsb文件的几个问题已得到修复,因此我建议您升级并尝试最新版本。

If you still have any problem, kindly provide me a runnable sample code and template .xlsb file, I will check your issue and try to help. 如果您还有任何问题,请提供一个可运行的示例代码和模板.xlsb文件,我会检查您的问题并尝试提供帮助。
You can also post questions on https://forum.aspose.com/ if any. 您也可以在https://forum.aspose.com/上发布问题(如果有的话)。

Note : I am working as Developer Evangelist at Aspose. 注意 :我在Aspose担任开发人员传播者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM