how to display excel sheet in html page

后端 未结 11 1730
天涯浪人
天涯浪人 2020-12-03 21:09

I want to display EXCEL sheet embedded in IE with plain HTML. I have gone through other questions on stackoverflow but could not find any useful one.

Here is my html

11条回答
  •  日久生厌
    2020-12-03 22:05

    Like you, I cannot get MS Office Web Components to work. I would not consider Google Docs since Google seems to think they own anything that passes through their hands. I have tried MS Publish Objects but the quality of the generated html/css is truely awful.

    The secret of converting an Excel worksheet to html that will display correctly on a smartphone is to create clean, lean html/css.

    The structure of the HTML is:

    
    
      
        HEAD
      
      
        BODY
      
    
    

    There are useful html elements that can replace "HEAD" but it is not clear to me how you would generate them from an Excel worksheet. They would need to be added separately.

    The obvious output for a worksheet or a range is an html table so the following assumes BODY will be replaced by an html table.

    The structure of an html table is:

    
        More  elements as necessary
      
      More ... as necessary
    
    CELL-VALUE...

    Include as few TABLE-ATTRIBUTES, TABLE-ROW-ATTRIBUTES and TABLE-CELL-ATTRIBUTES as possible. Do not set column widths in pixels. Use css attributes rather than html attributes.

    A table attribute worth considering is style = "border-collapse: collapse;". The default is separate with a gap around each cell. With collapse the cells touch as they do with Excel.

    Three table attribute worth considering are style="background-color:aliceblue;", style="color:#0000FF;" and style="text-align:right;". With the first, you can specify the background colour to be any of the fifty or so named html colours. With the second, you can specify the font colour to be any of 256*256*256 colours. With the third you can right-align numeric values.

    The above covers only a fraction of the formatting information that could be converted from Excel to html/css. I am developing an add-in that will convert as much Excel formatting as possible but I hope the above helps anyone with simple requirements.

提交回复
热议问题