question

ShridharSharma avatar image
0 Votes"
ShridharSharma asked David-9140 Suspended answered

create and save file as xlsb extension C#

Straight Question : Facing problem in creating and saving .xlsb type file in C# and save this to preferred location. Tried Microsoft.Office.Interop.Excel to do so with no luck. Intend is to change the existinf xlsx type into xlsb type in order to reduce file size . Is there known package to implement this ask ?

Thanks,
iShriss

dotnet-csharp
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JackJJun-MSFT avatar image
0 Votes"
JackJJun-MSFT answered JackJJun-MSFT edited

Hi @ShridharSharma ,


You can try the following steps to convert xlsx type to xlsb type in c#.

First, please install the nuget-package Aspose.Cells in your app.

Second, please try the following code to convert.

     var book = new Aspose.Cells.Workbook("E:\\Example.xlsx");
     // save XLSX as XLSB
     book.Save("E:\\output.xlsb", Aspose.Cells.SaveFormat.Auto);

Finally, you can get the output.xlsb file and the file size is reduced.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Girraj-1837 avatar image
0 Votes"
Girraj-1837 answered

kindly suggest the way if we can create or save a .xlsb blank file using Microsoft.Office.Interop.Excel using C#.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

David-9140 avatar image
0 Votes"
David-9140 Suspended answered

This task can also be achieved by using Spire.XLS for .NET.

Below is the code example for your reference.

 using Spire.Xls;
    
 namespace ConvertToXlsb
 {
     class Program
     {
         static void Main(string[] args)
         {
             Workbook wb = new Workbook();
             wb.LoadFromFile(@"C:\Users\Administrator\Desktop\source.xlsx");
             wb.SaveToFile("output.xlsb", ExcelVersion.Xlsb2010);
         }
     }
 }


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.