Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Excel to HTML gridlines missing in Google Chrome

Tags:

html

excel

I'm trying to convert from excel spreadsheet (.xls) to html via MS Excel 2010, but I'm wanting to keep the gridlines. So I'm highlighting all cells -> format cells -> outline and inside border presets, normal border, black color, and then doing the export. Viewed with IE and Firefox, the borders are there. However, when viewed with chrome, the borders are gone and I instead see style="border-left: none;" inside of each td tag.

The purpose of this is to make an excel spreadsheet preview for a webpage, and it's looking like the export-to-html route is probably the easiest. Does anyone know of a better route?

I'm thinking my only solution may be to just have javascript check specifically for chrome and edit the border left/right/top/bottom styles on all the td tags. Is there something I'm missing?


Also, is there a way to keep the row numbers and column letter headers in the html version?

like image 220
Brad T. Avatar asked Jun 20 '11 20:06

Brad T.


1 Answers

You can do a find/replace for all the instances where the source code reads border-left:none, border:none, etc... then use css styles to make sure the gridlines stay with the data. Assuming it is exported as a table, use

<style type="text/css">
    table{
       border: 2px solid #000000;
    }
    td{
       border: 1px solid #000000;
    }
</style>

(format to your own taste and liking)

As for the row numbers and column headers, it depends how much data you have. If there's not much, it would be easiest to hand-type in the headings and numbers. If it's a lot, the best way would be to use javascript or a server-side language to print out the row headings for you.

like image 123
alquatoun Avatar answered Sep 19 '22 13:09

alquatoun