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.

Sun Apr 20, 2014 8:21 pm

Hello,

Using Spire.XLS I was able to export a HTMl file from Excel (xlsx). But, what if what I actually need is NOT a saved HTML file but just the text string which consists of all the content from the Excel with embedded html tags? Is there a method within Spire.XLS that generates this html string only?

Thanks!

kkim1975
 
Posts: 1
Joined: Sun Apr 20, 2014 2:10 pm

Mon Apr 21, 2014 8:39 am

Hello,

Thanks for your inquiry.
Sorry that at present our Spire.PDF doesn't have a direct method to convert Excel to html string.
But you could try firstly save Html to a stream and then convert the stream to string.
Code: Select all
   using (MemoryStream ms = new MemoryStream())
            {
                wb.Worksheets[0].SaveToHtml(ms);
                File.WriteAllBytes("Sample.txt",ms.ToArray());
            }


Feel free to contact us if you have any problems.

Best wishes,
Amy
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu Apr 24, 2014 9:21 am

Hello,

Have you tried the method provided by Amy? Does it fulfill your need? Could you please give us some feedback if convenience?

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Sat May 03, 2014 12:39 am

Code: Select all
            String htmlString = "";
            using (MemoryStream ms = new MemoryStream())
            {
                wb.Worksheets[0].SaveToHtml(ms);
                htmlString  = System.Text.Encoding.UTF8.GetString(ms.ToArray());
            }


That will write it to a string.

jon_x
 
Posts: 2
Joined: Sat May 03, 2014 12:33 am

Mon May 05, 2014 1:36 am

Hello,

Many thanks for sharing your code.
Feel free to contact us if you have any problems.

Best wishes,
Amy
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.XLS