Free Support Forum -

Aspose Cells: Saving mht file- reading in aspose is a problem

I receive an output in “mht”, saving it using IO no problem, then open it using excel so problem too. Trying to open it through aspose I got a problem regarding using LoadOption as XLS or MHT, it give the same problem:

System.FormatException: Invalid character in a Base-64 string. at
System.Convert.FromBase64String(String s) at Ž“.˜.‡(Stream , String ,
String , Encoding ) at Ž“.˜.(StreamReader , Encoding ) at
Ž“.˜.–‰(Stream , Encoding ) at Ž“.›.˜‰(Stream , Workbook , LoadOptions )
at Aspose.Cells.Workbook.Ÿ(Stream , LoadOptions , Boolean ) at
Aspose.Cells.Workbook.Ÿ(String , LoadOptions ) at
Aspose.Cells.Workbook…ctor(String file, LoadOptions loadOptions).

If I try to save the stream directky into a workbook I got the same problem.

Now, if I save it in XLS file, then open it through excel and save it. Aspose was able to open it.



Thanks for using Aspose.Cells for .NET.

Please download and try the latest version:
for .NET v7.3.2.3

and see if it works fine.

I have tested your issue with the latest version using the following code but I could not replicate it. It works fine. I have also attached the output mhtml and xlsx file generated by this code.

If you still find any problem, then please provide us your simple runnable sample code/project replicating this issue. We will check it at our end and resolve this issue.


string filePath = @“F:\Shak-Data-RW\Downloads”;

Workbook workbook = new Workbook();

Worksheet worksheet = workbook.Worksheets[0];

worksheet.Cells[“A1”].PutValue(“Hello Aspose!”);

workbook.Save(filePath + “output.mht”, SaveFormat.MHtml);

workbook = new Workbook(filePath + “output.mht”);

workbook.Save(filePath + “output.xlsx”, SaveFormat.Xlsx);



Aspose.Cells does support to read and write MHT/MHTML files. Please first of all try the latest fix v7.3.2.3 (as Shakeel Faiz shared the link in the above post) if it works fine. If you have your MHT / XLS file and you are trying to read it via Aspose.Cells but you are finding a problem/exception, please attach the file here. We will check it soon.

Thank you.

I did download the latest version (2 days ago). The issue is to read an MHT formatted file create by other system. The same created file is readable by Excel and any browser. I am attaching a sample file, please try to open it programatically:

Dim loadOptions As New Aspose.Cells.LoadOptions(Aspose.Cells.LoadFormat.MHtml)

Dim wb As Aspose.Cells.Workbook = New Aspose.Cells.Workbook("testmht.mht", loadOptions)

I can read it throughFilestream and save it, but cannot open it or save the stram into a workbook.

I could save the file using system.IO in xls, mht and excel still can open it, but not aspose



Thanks for your sample MHTML file.

We were able to replicate this issue using the latest version:
for .NET v7.3.2.
3 with the following sample code and it throws the given exception.

I have attached the screenshot showing the exception for your reference.

We have logged this issue in our database. We will look into it and fix the issue. Once the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-41137.


string filePath = @“F:\Shak-Data-RW\Downloads\TestMHT.mht”;

Workbook workbook = new Workbook(filePath);

An unhandled exception of type 'System.FormatException' occurred in Aspose.Cells.dll

Additional information: Invalid character in a Base-64 string.



We have fixed this issue.

Please download and try this fix: Aspose.Cells for .NET v7.3.2.4 and let us know your feedback.

Thank you for replying and addressing the issue in short, short time.

The system does not return any error and it does save data in excel.

Now, my problem, I lost all formatting when file is saved.

Reason I get my data in mhtml for the formatting. So it is imperative that I keep all formatting. Thanks again


Thanks for your feedback.

We were able to replicate this issue using the latest version. We have logged this issue in our database. We will look into it and fix this issue.

Once, we will have some update for you, we will let you know asap.

This issue has been logged as CELLSNET-41144.

Below is a sample test code. I have attached the output xls file and screenshot for your reference.


string filePath = @“F:\Shak-Data-RW\Downloads\TestMHT.mht”;

var workbook = new Workbook(filePath);


workbook.Save(filePath + “.out.xls”);


The issues you have found earlier (filed as CELLSNET-41137) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

I downloaded the new version and run a test. Again, saving file in Aspose.cells will loose all formatting. In addition, when trying to “Click to Edit”, I got worksheet errors (2).


Thanks for your feedback.

Actually, your issue relating to losing the formatting in xls output file is still unresolved i.e CELLSNET-41144

The above notification is for your first issue only.

Once, this issue is fixed, we will notify you again by posting here.


We have fixed the text format issue in the latest aspose version

However, this template file is not a standard mhtml file saved by MS Excel.

So, some details could not be parsed so perfectly now.

Please download and try this fix: Aspose.Cells for .NET v7.3.3.2 and let us know your feedback.

I tried it and got the same result, NO FORMATTING at all.

Plus the system adds extra blank rows (top).

This file is not generated by Excel, however, if I saved it as is (without going to Aspose) and then open it in Excel, all formatting were preserved.

The reason to use Aspose, so I could add header/footer and Password Protection.

Please let me know when this is corrected.

If you need additional information, p,ease call me 1 (508) 222-5593 EST



Thanks for using Aspose.Cells for .NET

Since, your html is not a standard html as generated by Ms-Excel and Aspose.Cells follow the Ms-Excel html standards, so this issue could not be resolved completely.

However, we will investigate this issue further and see if it can be improved. Once there is some update for you, we will let you know asap.


Thanks for your posting and using Aspose.Cells,

We have already fixed the text formatting issue in the version:
for .NET v7.3.3.2

Please use the following sample code and let us know your feedback.


string filePath = @“D:\html\TestMHT.mht”;

Workbook book = new Workbook(filePath);


book.Save(filePath + “.out.xls”);

You could see the text formatting in the output file. Please see the screenshot below for your reference.



Please try our new official release of the product v7.3.4:
We have fixed the issue filed as “CELLSNET-41137” in it.

Thank you.

FOr the second time I gave it a try and still loosing the initial formatting. I could save the file in MHT or XLS and if open directly in Excell then all formatting are intact.

Now opening the same file in Aspose, I loose all format. Any additional format added to the sheet the Aspose will save them.

The same if saved in Excel then the Aspose will keep all formatting



We are sorry for your inconvenience.

We actually notified you that the official release (v7.3.4) does include the fix filed as: “CELLSNET-41137” in it. This issue refers to the reading problem that you were initially facing for your template (.MHT) file, see the screen shot here:

For your second issue, as my fellow colleague told you that since your file is not standard html file, so some formatting might be lost and we might not fix it completely. Anyways, we did fix it to certain extent (issue was logged as “CELLSNET-41144”). By the way, could you give us your template file and output file here, also provide us the sample code and attach some screen shots to show the formatting issue (you may highlight the problematic areas in red color) for our ease. We will check it further soon.

Thank you.