By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,396 Members | 1,869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,396 IT Pros & Developers. It's quick & easy.

Strip css from Excel-generated file

P: n/a

I need to pull several tables of data from Excel into a web page, but
when I use Excel's "Save as web page" function, I get an enormous file
containing a massive amount of css formatting. I'd like to strip out
this css so that I can apply my own style sheet; does anyone know
whether there is a way to do this, other than manually? Either a way to
export the data from Excel that doesn't include the css formatting, or
a utility that will strip it out for me?

Julie
--
Never ascribe to malice that which can be
adequately accounted for by stupidity
Jul 20 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Thu, 23 Oct 2003 10:29:30 -0600, Julie Miles wrote:

I need to pull several tables of data from Excel into a web page, but
when I use Excel's "Save as web page" function, I get an enormous file
containing a massive amount of css formatting. I'd like to strip out
this css so that I can apply my own style sheet; does anyone know
whether there is a way to do this, other than manually? Either a way to
export the data from Excel that doesn't include the css formatting, or
a utility that will strip it out for me?


Quick response:

I don't have Excel, but on Word (XP at least) you can choose File --> Save
As --> Save As Type. There's Web Page and under that something like "Web
Page <something>" which doesn't add the M$ Office Bloat.

--
Matt
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 20 '05 #2

P: n/a
On Thu, 23 Oct 2003 10:29:30 -0600, Julie Miles <jm****@unibase.com>
wrote:

I need to pull several tables of data from Excel into a web page, but
when I use Excel's "Save as web page" function, I get an enormous file
containing a massive amount of css formatting. I'd like to strip out
this css so that I can apply my own style sheet; does anyone know
whether there is a way to do this, other than manually? Either a way to
export the data from Excel that doesn't include the css formatting, or
a utility that will strip it out for me?


Simplest way is probably as follows. Insert new columns around the
existing columns: the first containing <TR><TD>, the last with
</TD></TR> and all the others with </TD><TD>. Obviously the Excel "fill
down" function is very handy. Save the file as text. That gets most of
the work done.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Jul 20 '05 #3

P: n/a
In article <pa****************************@hotmail.com>,
ma**********@hotmail.com says...
On Thu, 23 Oct 2003 10:29:30 -0600, Julie Miles wrote:

I need to pull several tables of data from Excel into a web page, but
when I use Excel's "Save as web page" function, I get an enormous file
containing a massive amount of css formatting. I'd like to strip out
this css so that I can apply my own style sheet; does anyone know
whether there is a way to do this, other than manually? Either a way to
export the data from Excel that doesn't include the css formatting, or
a utility that will strip it out for me?


Quick response:

I don't have Excel, but on Word (XP at least) you can choose File --> Save
As --> Save As Type. There's Web Page and under that something like "Web
Page <something>" which doesn't add the M$ Office Bloat.

Thanks, Matt, but there doesn't seem to be any corresponding function
in Excel. I think the simplest way around this might be to convert the
file to .pdf rather than an html page.

--
Never ascribe to malice that which can be
adequately accounted for by stupidity
Jul 20 '05 #4

P: n/a
In article <7n********************************@4ax.com>,
sb*****@xs4all.nl says...
On Thu, 23 Oct 2003 10:29:30 -0600, Julie Miles <jm****@unibase.com>
wrote:

I need to pull several tables of data from Excel into a web page, but
when I use Excel's "Save as web page" function, I get an enormous file
containing a massive amount of css formatting. I'd like to strip out
this css so that I can apply my own style sheet; does anyone know
whether there is a way to do this, other than manually? Either a way to
export the data from Excel that doesn't include the css formatting, or
a utility that will strip it out for me?


Simplest way is probably as follows. Insert new columns around the
existing columns: the first containing <TR><TD>, the last with
</TD></TR> and all the others with </TD><TD>. Obviously the Excel "fill
down" function is very handy. Save the file as text. That gets most of
the work done.

That's an ingenious suggestion! I think it will work for most of them -
there are some that have more complex structures (merged cells), but it
certainly gets rid of the majority of the grunt work. Thanks!

Julie
--
Never ascribe to malice that which can be
adequately accounted for by stupidity
Jul 20 '05 #5

P: n/a
Julie Miles wrote:

I need to pull several tables of data from Excel into a web page, but
when I use Excel's "Save as web page" function, I get an enormous
file containing a massive amount of css formatting. I'd like to strip
out this css so that I can apply my own style sheet; does anyone know
whether there is a way to do this, other than manually? Either a way
to export the data from Excel that doesn't include the css
formatting, or a utility that will strip it out for me?


Next to the <tr><td> hack which is very good, you can use Tidy HTML.
It's got special functions to clean Word-bloat etc. but it basically
cleans up any HTML, converts to XHTML etc.
http://www.w3.org/People/Raggett/tidy/
--
Google Blogoscoped
http://blog.outer-court.com
Jul 20 '05 #6

P: n/a
Wow, I remember that someone wrote a DeCSS program to remove CSS from web
pages. (OK it was mainly to confuse 'bots looking for some other DeCSS
program). This might be an actual use for it.

Julie Miles wrote:

I need to pull several tables of data from Excel into a web page, but
when I use Excel's "Save as web page" function, I get an enormous file
containing a massive amount of css formatting. I'd like to strip out
this css so that I can apply my own style sheet; does anyone know
whether there is a way to do this, other than manually? Either a way to
export the data from Excel that doesn't include the css formatting, or
a utility that will strip it out for me?

Julie


Jul 20 '05 #7

P: n/a
Julie Miles <jm****@unibase.com> wrote:
I need to pull several tables of data from Excel into a web page,
but when I use Excel's "Save as web page" function, I get an
enormous file containing a massive amount of css formatting.


There are several approaches, some of which have been mentioned here.
I'd like to add two more:

1. Save in TSV format (tab separated values) and use some simple
utilitity like a short Perl script to convert the TSV file
to simple HTML markup. More on this:
http://www.cs.tut.fi/~jkorpela/TSV.html

2. Download Office 2000 Filter from Microsoft:
<http://www.microsoft.com/downloads/details.aspx?
FamilyID=209ADBEE-3FBD-482C-83B0-96FB79B74DED&displaylang=EN>
For Excel files, you would run the filter from the Start menu,
item Microsoft Office Tools. In the program, click on the
Options button to make it string standard CSS too (it by
default strips Microsoft-specific CSS only).
Problem: It leaves HTML attributes intact, making the table
foolishly rigid. You could use some other software on it,
or just try to override those attributes using CSS (e.g.,
overriding a pixel-valued width or height attribute with
a CSS rule that uses the em unit or the value 'auto').

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 20 '05 #8

P: n/a
On Thu, 23 Oct 2003 13:17:46 -0600, Julie Miles <jm****@unibase.com> wrote:

[snip]
Simplest way is probably as follows. Insert new columns around the
existing columns: the first containing <TR><TD>, the last with
</TD></TR> and all the others with </TD><TD>. Obviously the Excel "fill
down" function is very handy. Save the file as text. That gets most of
the work done.

That's an ingenious suggestion! I think it will work for most of them -
there are some that have more complex structures (merged cells), but it
certainly gets rid of the majority of the grunt work. Thanks!

Julie


Several months ago I wrote an Excel function for this purpose: It can
handle merged cells and it reads the names(!) of Excel styles (not the
style definitions) and translates them into CSS class attributes.

To make it work, paste the following code into an Excel module (Fire the
VBA editor with Alt + F11, find your workook in one of the left windows,
right-click on it, then "Insert - Module" , doubleclick the newly created
module and paste the code).

If the first line of your Excel table stretches from A1 to D1, then in E1
you could use the formula =row2html(A1:D1)
Copy the formula down to the last cell.

Cheers,
Joerg

Here comes the Excel Stuff:
Function row2html(DataRange As Object)
'Purpose: To mark-up a horizontal cell range as HTML <tr><td> elements
'How it works: Each cell contents enclosed with <td>..</td> tags. The
whole stuff with <tr>..</tr> tags.
'Special functions: Reads style names and converts them to class
attributes, translates merged cells into colspans.
'Applies to: Horizontal cell ranges
On Error Resume Next
Dim CellText As String
Application.Volatile
txt = "<tr>"
'If DataRange.MergeCells = True Then MsgBox "contains merged cells"
Colspan = 0
For Each cell In DataRange
ColSpanAttribute = ""
If cell.MergeArea.Address <> cell.Address And ColSpanProcessed =
True Then
'Do nothing if cell is part of a merged area and TD with
COLSPAN attribute has already been defined
'Ignore cell until last cell reached, then reset
ColSpanProcessed (another merged area may follow and has to be processed
with a clean slate)
Colspan = Colspan - 1
If Colspan = 1 Then ColSpanProcessed = False
Else
'Define COLSPAN if cell is part of merged area
If cell.MergeArea.Address <> cell.Address And ColSpanProcessed
= False Then
Colspan = cell.MergeArea.Cells.Count
ColSpanAttribute = " colspan=""" & Colspan & """"
ColSpanProcessed = True
End If

CellText = cell.Value
'Add CSS class names, if cell contains named style
If cell.Style.Name = "Normal" Then
txt = txt & "<td" & ColSpanAttribute & ">" & CellText &
"</td>"
Else
txt = txt & "<td class=""" & cell.Style.Name & """" &
ColSpanAttribute & ">" & CellText & "</td>"
End If
End If
Next cell
txt = txt & "</tr>"
row2html = txt
End Function
Jul 20 '05 #9

P: n/a
In article <Xn*****************************@193.229.0.31>,
jk******@cs.tut.fi says...
Julie Miles <jm****@unibase.com> wrote:
I need to pull several tables of data from Excel into a web page,
but when I use Excel's "Save as web page" function, I get an
enormous file containing a massive amount of css formatting.


There are several approaches, some of which have been mentioned here.
I'd like to add two more:

1. Save in TSV format (tab separated values) and use some simple
utilitity like a short Perl script to convert the TSV file
to simple HTML markup. More on this:
http://www.cs.tut.fi/~jkorpela/TSV.html

2. Download Office 2000 Filter from Microsoft:
<http://www.microsoft.com/downloads/details.aspx?
FamilyID=209ADBEE-3FBD-482C-83B0-96FB79B74DED&displaylang=EN>
For Excel files, you would run the filter from the Start menu,
item Microsoft Office Tools. In the program, click on the
Options button to make it string standard CSS too (it by
default strips Microsoft-specific CSS only).
Problem: It leaves HTML attributes intact, making the table
foolishly rigid. You could use some other software on it,
or just try to override those attributes using CSS (e.g.,
overriding a pixel-valued width or height attribute with
a CSS rule that uses the em unit or the value 'auto').


Thanks to everyone for your helpful and creative suggestions - I truly
appreciate the help!

Julie
--
Never ascribe to malice that which can be
adequately accounted for by stupidity
Jul 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.