I have an excel which needs to be saved as HTML file. I tried in general way to send hotkeys and save it as HTML, but after automating everything correctly, in the end Bot is still saving the file as Excel only. Because in Save as Window, Bot is giving the file name and selecting the Type as html but after clicking the the save button, the type is automatically getting changed to Excel again. is there any other alternatives to change the excel file to html file? I tried invoke code using the following code, but it didn’t work
using Spire.Xls;
namespace XLSToHTML
{
class Program
{
static void Main(string args)
{
//Create a Workbook instance
Workbook workbook = new Workbook();
//Load an Excel sample document
workbook.LoadFromFile(@"sample.xlsx");
//Get the first worksheet of the document
Worksheet sheet = workbook.Worksheets[0];
//Save the worksheet to HTML
sheet.SaveToHtml("ExcelToHTML.html");
}
}
}
it is showing the error as closing } is needed although everything seems to be working in VB Studio. Can anyone please resolve this issue?
If you are sure that the contents of your excel would be readable as html, I guess you can try just letting the bot save it as an excel and then just add a sequence to rename the file from ExcelFile.xlsx to ExcelFile.html
Have not tried if, but I think it might work.
Hi, Thanks for the code but there is a small thing missing, I am not getting Colomn Names from the excel file. can you update the code with adding colomn names as well when converting to HTML file?
// Create an instance of the class used to import/export Excel files
ExcelDocument workbook = new ExcelDocument();
// Import Excel file
workbook.easy_LoadXLSXFile("C:\\Samples\\file.xlsx");
// Export HTML file
workbook.easy_WriteHTMLFile("C:\\Samples\\Excel to HTML.html");