Strip css from Excel-generated file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Julie Miles

    Strip css from Excel-generated file


    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
  • Matt

    #2
    Re: Strip css from Excel-generated file

    On Thu, 23 Oct 2003 10:29:30 -0600, Julie Miles wrote:
    [color=blue]
    >
    > 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?[/color]

    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! =-----

    Comment

    • Stephen Poley

      #3
      Re: Strip css from Excel-generated file

      On Thu, 23 Oct 2003 10:29:30 -0600, Julie Miles <jmiles@unibase .com>
      wrote:
      [color=blue]
      >
      >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?[/color]

      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


      Comment

      • Julie Miles

        #4
        Re: Strip css from Excel-generated file

        In article <pan.2003.10.23 .17.52.54.68914 4@hotmail.com>,
        mattblissett@ho tmail.com says...[color=blue]
        > On Thu, 23 Oct 2003 10:29:30 -0600, Julie Miles wrote:
        >[color=green]
        > >
        > > 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?[/color]
        >
        > 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.
        >
        >[/color]
        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

        Comment

        • Julie Miles

          #5
          Re: Strip css from Excel-generated file

          In article <7n7gpvs2o0hebt b0fdb908supco75 5603p@4ax.com>,
          sbpoley@xs4all. nl says...[color=blue]
          > On Thu, 23 Oct 2003 10:29:30 -0600, Julie Miles <jmiles@unibase .com>
          > wrote:
          >[color=green]
          > >
          > >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?[/color]
          >
          > 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.
          >
          >[/color]
          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

          Comment

          • Philipp Lenssen

            #6
            Re: Strip css from Excel-generated file

            Julie Miles wrote:
            [color=blue]
            >
            > 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?
            >[/color]

            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.



            --
            Google Blogoscoped

            Comment

            • Stuart Scharf

              #7
              Re: Strip css from Excel-generated file

              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:
              [color=blue]
              >
              > 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[/color]

              Comment

              • Jukka K. Korpela

                #8
                Re: Strip css from Excel-generated file

                Julie Miles <jmiles@unibase .com> wrote:
                [color=blue]
                > 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.[/color]

                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:


                2. Download Office 2000 Filter from Microsoft:
                <http://www.microsoft.com/downloads/details.aspx?
                FamilyID=209ADB EE-3FBD-482C-83B0-96FB79B74DED&di splaylang=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/

                Comment

                • Joerg

                  #9
                  Re: Strip css from Excel-generated file

                  On Thu, 23 Oct 2003 13:17:46 -0600, Julie Miles <jmiles@unibase .com> wrote:

                  [snip][color=blue][color=green]
                  >> 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.
                  >>
                  >>[/color]
                  > 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[/color]

                  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(DataRa nge 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.Vol atile
                  txt = "<tr>"
                  'If DataRange.Merge Cells = True Then MsgBox "contains merged cells"
                  Colspan = 0
                  For Each cell In DataRange
                  ColSpanAttribut e = ""
                  If cell.MergeArea. Address <> cell.Address And ColSpanProcesse d =
                  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
                  ColSpanProcesse d (another merged area may follow and has to be processed
                  with a clean slate)
                  Colspan = Colspan - 1
                  If Colspan = 1 Then ColSpanProcesse d = False
                  Else
                  'Define COLSPAN if cell is part of merged area
                  If cell.MergeArea. Address <> cell.Address And ColSpanProcesse d
                  = False Then
                  Colspan = cell.MergeArea. Cells.Count
                  ColSpanAttribut e = " colspan=""" & Colspan & """"
                  ColSpanProcesse d = True
                  End If

                  CellText = cell.Value
                  'Add CSS class names, if cell contains named style
                  If cell.Style.Name = "Normal" Then
                  txt = txt & "<td" & ColSpanAttribut e & ">" & CellText &
                  "</td>"
                  Else
                  txt = txt & "<td class=""" & cell.Style.Name & """" &
                  ColSpanAttribut e & ">" & CellText & "</td>"
                  End If
                  End If


                  Next cell
                  txt = txt & "</tr>"
                  row2html = txt
                  End Function

                  Comment

                  • Julie Miles

                    #10
                    Re: Strip css from Excel-generated file

                    In article <Xns9420F04DE31 FFjkorpelacstut fi@193.229.0.31 >,
                    jkorpela@cs.tut .fi says...[color=blue]
                    > Julie Miles <jmiles@unibase .com> wrote:
                    >[color=green]
                    > > 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.[/color]
                    >
                    > 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=209ADB EE-3FBD-482C-83B0-96FB79B74DED&di splaylang=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').[/color]

                    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

                    Comment

                    Working...