dimanche 29 mars 2015

Saving Excel File as HTML(Cell Formatting is not shown in converted HTML)

I am trying to save Excel Sheet to HTML using Office Interope libraries. Everything works fine but formatted cells are not shown as they are in excel sheet. Here is how it looks in MS Excel


enter image description here


And here is what it looks like after conversion in HTML


enter image description here


Here is the code I am using to save Excel sheet as HTML



xApp = new Microsoft.Office.Interop.Excel.Application();
object missing = Type.Missing;
object trueObject = true;
xApp.Visible = false;
xApp.DisplayAlerts = false;
xWorkBook = xApp.Workbooks.Open(ExcelFilePath, missing, trueObject, missing,
missing, missing,missing, missing, missing, missing, missing, missing,
missing, missing, missing);
object format = Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml;
xWorkBook.SaveAs(tempFileName, format, missing, missing, missing, missing,
Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange,
missing, missing, missing,missing, missing);

Aucun commentaire:

Enregistrer un commentaire