如何使用Aspose.cells实例化Office 365 Excel文件



当我尝试创建从Office 365环境生成的Excel文件的实例(.XLSB格式(时,它正在抛出错误。

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

上面的代码正在抛出以下错误:

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");

有关进一步的参考,请检查不同的Wiki主题以满足您的需要:http://www.aspose.com/wiki/default.aspx/aspose.cells/

我试图通过创建.xlsb文件的实例来重现问题,并且在最新的Aspose.cells版本19.5。在v19.2中,固定和打开.xlsb文件的几个问题已修复,因此我建议您升级并尝试最新版本。

如果您仍然有任何问题,请为我提供可运行的示例代码和模板.xlsb文件,我将检查您的问题并尝试提供帮助。
您也可以在https://forum.aspose.com/上发布问题。

注意:我在Aspose中担任开发人员。

最新更新