Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed Nov 29, 2023 6:12 pm

I am trying to convert html table to excel.

string contents = "<html><body><h1>hello</h1></body></html>";
byte[] byteArray = Encoding.UTF8.GetBytes(contents);
MemoryStream stream = new MemoryStream(byteArray);
Workbook workbook = new Workbook();
workbook.LoadFromStream(stream);
//AutoFit rows
Worksheet sheet = workbook.Worksheets[0];
sheet.AllocatedRange.AutoFitRows();
//Save the document to file
workbook.SaveToFile("Result.xlsx", FileFormat.Version2010);[/list][/list]

The code " workbook.LoadFromStream(stream);" throws this exception. 'Zip exception.Can't locate end of central directory record. Possible wrong file format or archive is corrupt.'

Please help.

Bhuvaneshwari
 
Posts: 6
Joined: Wed Nov 29, 2023 6:08 pm

Thu Nov 30, 2023 1:31 am

Hello,

Thanks for your inquiry.
I have tested the code you provided using the latest version of Spire.XLS (Spire.XLS Pack(Hotfix) Version:13.11.4), but I was unable to reproduce the issue you mentioned. Could you please confirm if you have also tested it with the latest version?
In case you haven't, I recommend trying the code with the latest version as a first step. Additionally, you can modify the line "workbook.LoadFromStream(stream);" to "workbook.LoadFromHtml(stream);" and see if the issue persists.
If the issue still exist after these tests, please provide the following information. Thank you in advance.
1) Your test environment, such as OS info (E.g. Windows 10, 64-bit) and region setting (E.g. China, Chinese).
2) Your application type, such as Console app (. Net Framework 4.5).

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Thu Nov 30, 2023 6:41 am

Thnaks for ur reply. It worked when I upgraded to new version. Tat html was the sample one I tested.

String content = @"<!DOCTYPE html><html><head> <title></ title ></ head >< body > < table class='table table-striped dataTable' border='1' style='Width:1575px'> <tr> <td colspan = '21' align='center'>Nov-2023</td> </tr> <tr border = '0' > < td colspan='3' align='center'>Monday</td> <td colspan = '3' align='center'>Tuesday</td> <td colspan = '3' align='center'>Wednesday</td> <td colspan = '3' align='center'>Thursday</td> <td colspan = '3' align='center'>Friday</td> <td colspan = '3' align='center'>Saturday</td> </tr> </table></body></html>";

The above html is just one part of my actual html. It throws "Input string is not in correct format" error. Please help

Bhuvaneshwari
 
Posts: 6
Joined: Wed Nov 29, 2023 6:08 pm

Thu Nov 30, 2023 7:15 am

Hello,

Thank you for your feedback.
I tested your code and did reproduce the issue you mentioned. I have logged the issue into our bug tracking system with the ticket number SPIREXLS-5015. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Thu Nov 30, 2023 10:43 am

Thank you Annika. I have long html string needs to be converted to excel. If you can provide your emailId, I can share the html over email.

Bhuvaneshwari
 
Posts: 6
Joined: Wed Nov 29, 2023 6:08 pm

Thu Nov 30, 2023 2:29 pm

Hi Annika, Any update on the ticket?

Bhuvaneshwari
 
Posts: 6
Joined: Wed Nov 29, 2023 6:08 pm

Fri Dec 01, 2023 2:03 am

Hello,

Thank you for your feedback.
Please send the HTML content to our email address at [email protected]. Once we receive it, we will investigate as soon as possible.
Regarding the issue SPIREXLS-5015, I have checked our internal system records, and there haven't been any significant updates thus far. Rest assured that I will promptly inform you of any major progress regarding this issue. We appreciate your understanding and support.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Fri Dec 01, 2023 1:29 pm

Thanks Annika, I have shared the html. Please do the needful ASAP.

Bhuvaneshwari
 
Posts: 6
Joined: Wed Nov 29, 2023 6:08 pm

Mon Dec 04, 2023 1:53 am

Hello,

Thank you for sharing the HTML file via email.
I have tested the file you provided, and it resulted in an error message stating "Cannot read that as a ZipFile". I have escalated this issue to our development team for further investigation and resolution. They will address this matter along with the previous issue SPIREXLS-5015.
Rest assured that once a solution is found, I will promptly inform you. We appreciate your patience and understanding throughout this process.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Tue Dec 12, 2023 9:09 am

Hello,

Thanks for your patience!
Glad to inform you that we just released Spire.XLS Pack Version:13.12 which fixes your issue SPIREXLS-5015、SPIREXLS-5019.
Please download the fix version from the following links to test.
Website link: https://www.e-iceblue.com/Download/download-excel-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.XLS/13.12.0

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Wed Dec 13, 2023 12:51 pm

Thanks Team. I will check.

Bhuvaneshwari
 
Posts: 6
Joined: Wed Nov 29, 2023 6:08 pm

Thu Dec 14, 2023 1:16 am

Hello,

You're welcome.
If you encounter other issues related to our products in the future, please feel free to contact us.
Have a nice day.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.XLS

cron