Creating simple Excel file

  • Thread starter Thread starter Eric Johannsen
  • Start date Start date
E

Eric Johannsen

Hi,

Is there any open source / demo code that shows how to create a simple Excel
97 or later file without resorting to Interop?

My application currently creates a simple CSV file, but I would like it to
be able to create an XLS file with a single workbook, and add simple
attributes to the cells (color, font, value).

Searched GotDotNet and Source Forge, but didn't find anything yet.

Thanks,

Eric
 
Hi Eric

One way of getting simple formatting into Excel without interop is to create
a html file with table tags. Excel will happily read an html file
preserving foreground /background colours, alignment etc.

eg. a file like this

---------------------------------
<TABLE>
<TR>
<TH ALIGN><FONT FACE = "Arial" SIZE=6>Col Head 1</FONT></TH>
<TH><FONT FACE = "Arial" SIZE=6>Col Head 1</FONT></TH>
</TR>
<TR>
<TD ALIGN="LEFT" BGCOLOR=blue ><FONT FACE = "Arial" COLOR=White>Text
Value</FONT></TD>
<TD ALIGN="RIGHT" BGCOLOR=white><FONT FACE = "Times New Roman"
COLOR=red>12</TD>
</TR>
</TABLE>
---------------------

Looks like this when loaded into excel

Col Head 1 Col Head 1
Text Value 12




Geoff
 
Thanks, works like a charm!

Eric

news.blueyonder.co.uk said:
Hi Eric

One way of getting simple formatting into Excel without interop is to create
a html file with table tags. Excel will happily read an html file
preserving foreground /background colours, alignment etc.

eg. a file like this

---------------------------------
<TABLE>
<TR>
<TH ALIGN><FONT FACE = "Arial" SIZE=6>Col Head 1</FONT></TH>
<TH><FONT FACE = "Arial" SIZE=6>Col Head 1</FONT></TH>
</TR>
<TR>
<TD ALIGN="LEFT" BGCOLOR=blue ><FONT FACE = "Arial" COLOR=White>Text
Value</FONT></TD>
<TD ALIGN="RIGHT" BGCOLOR=white><FONT FACE = "Times New Roman"
COLOR=red>12</TD>
</TR>
</TABLE>
---------------------

Looks like this when loaded into excel

Col Head 1 Col Head 1
Text Value 12




Geoff
 
Back
Top