none
Exporting Excel sheet to HTML(Cell Formatting is not shown in converted HTML) RRS feed

  • Question

  • 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 the preview of Excel Sheet

    and Here is the Converted HTML


    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);

    • Moved by CoolDadTx Monday, March 30, 2015 1:55 PM Office related
    Monday, March 30, 2015 9:24 AM

Answers

  • Hi Adil Waqar,

    Based on my understanding the Office PIAs is used to automate Excel application. And as far as I test, even I save the workbook to HTML manually, the diagonal borders also are lost.

    Some features may be lost is expected when we converting from a one to another format since the target file format may not support it.

    If you do want to Excel keep the diagoal borders, I suggest that you try to submit the feedback from link below:
    Submit Feedback - Microsoft Support

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 31, 2015 3:04 AM
    Moderator