Let’s say you have an Excel file you need to convert to HTML to put it on the web site. Below I’ll present some reasons why copy & paste or saving as HTML (hypertext markup language) simply doesn’t work fine and a solution to do convert it fine.
The situation described here implies that you have a HTML page, a table that only changes its data (so it doesn’t change table header or anything else in the page, just the numbers inside the table) and you need to make a lot of changes fast.
Sure, the easy option would be saving the file in Microsoft Excel software, and dealing with the way it looks afterwards. Or just a copy & paste from Excel to a CMS (Content Management System).
Say we have this file.
Unfortunately, whether you do copy & paste from Excel or you save as HTML, the result is this.
As you can see, a lot specifications and numbers, which make the tables difficult to manipulate:
Saving the file in Excel as HTML doesn’t yield any better results.
The code looks even uglier:
<tr height=20 style=’height:15.0pt’>
<td height=20 style=’height:15.0pt’></td>
What to do?
One solution would be taking the code and using a solution to strip the unnecessary code (a HTML editor, a search & replace macro in Word, etc.).
The solution below is different: I will take the data in Excel, place it in Word, run a macro, and get a valid code.
The very first thing to do is open up this file. You should either allow macros to run if you’re on Microsoft Office 2007, or set the proper security level to allow macros (Tools => Options => Security => Macro Security will work for 2003 version).
Then you should copy the macros that are attached to the file to your local computer. How to do that?
In Word 2003: Tools => Macro => Macros => Organizer
In Word 2007: View => Macros => View macros => Organizer
That’s it, now you have macros in your Word software.
(optional) You can assign an icon to the toolbar for fast launch of the macro you’ve just copied. For this, click the drop-down option in the ribbon, and select More commands (for Office 2007):
Or right-click a toolbar and select „Customize toolbars”;
For Office 2003, you go to Commands, then macros, and via drag & drop, you drag the macro to the toolbar, rename it and give it an icon.
2. In Microsoft Word either do Paste (a small arrow underneath the button) => Paste Special in Microsoft Word 2007 or Edit => Paste Special … in earlier versions; Ctrl + Alt + V also works just fine;
Select Unformatted text, Ok;
3. Launch the macro via either the toolbar button or View => Macros => View macros => Select „Replace_table” => Run (for Office 2007) or Tools => Macros => Macro => Select the macro => Run (for Office 2003);
4. Copy the code into the CMS.
And this is how I would make a code based on an Excel file.
Last modified on: 2013.10.19, at: 15:51.Share on WhatsApp