简体   繁体   中英

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.

 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/

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.
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.

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.
You can also post questions on https://forum.aspose.com/ if any.

Note : I am working as Developer Evangelist at Aspose.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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