LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Programmatically create html as input to Excel

Create a small example report in Excel using the formatting you want - then
export to HTML
and look at the source of the file. That should give you some idea of how
to go about this.

In the past I've used HTML exported from Excel as a template and just
replaced tokens with the actual content.

Tim


"scottb2" wrote in message
...
Tim,

The data file used to be output sent directly to a printer. It is now
sent
to a hard disc file to be read online. The current program, written in
assembler and invoked by IE for example, reads the data file and writes
either HTML or text lines to stdio back to the browser which displays the
data.

I'm enhancing this program to have Excel be a third target. The HTML
CONTENT-TYPE it creates invokes the Excel application. The program also
formats the data into columns by using <table<tdline1 data</td<tdline2
data</td...</table. The formatting seems to work very well except for
the
problems I listed at the first post.

If you're wondering why assembler, the shop has an entire environment
built
around assembler code running under Linux. There's a lot of history. So,
running VB code isn't an option. This is why I'm asking how to do this
from
the perspective of an HTML file as input to Excel.

From HTML (as input to Excel), I don't know how to force the use of a
fixed
sized font, etc.

Some of the problems I listed may be Excel problems when using HTML as
input
(number formatting issues). Maybe Excel just doesn't do what I'm needing
(using the font I want).

Thanks,
Scott

"Tim Williams" wrote:

How are you getting the information into Excel ? Are you using a macro or
some other method ?

ActiveCell.Font.Name = "Courier" 'proportional font
ActiveCell.Interior.Color = vbRed shading

ActiveSheet.Columns(10).NumberFormat = "0.00"

'replace trailing/leading spaces and single quotes
Dim c As Range
For Each c In ActiveSheet.UsedRange.Cells
c.Value = Trim(c.Value)
c.Value = Replace(c.Value, "'", "")
Next c

Your best bet is to turn on the macro recorder and do some formatting,
then
look at the code.

Tim


"scottb2" wrote in message
...
I'm trying to use fixed format information in a file (used to be
printed)
to
Excel 2003. One goal is to try to make the spreadsheet look as close
to
the
data file as possible. I'm also trying to disturb the user's
environment
as
little as possible and drive Excel from the program. I'm currently
filling
in the proper cells with the right data but have some limitations that
I'd
like to overcome.

Can I tell Excel to use a fixed-sized font?

Can I tell Excel to use a red background for selected cells without
knowing
the cell number?

A column may not always have numbers (perhaps column headers, etc.)
Can I
indicate that if a cell in column 10, 11, or 13 is numeric, it should
be
formatted to always have two decimal places? It should still remain a
number
and not be converted to text, kind of like using
Format-Cell-Number-Currency.

Sometimes a number (250.00 and -332.11, both with following spaces)
will
not
be converted to a number. The cell has an error message of "The number
in
this cell is formatted as text or preceeded by an apostrophe." What do
I
need to do to get rid of the error?

I tried preceeding all numbers in the column with an "=" so the numbers
ended up being "= 250.00" [space follows the equal] or "=-322.11"
[minus
sign
replaced the space"]. That caused a different error on other cells:
"The
formula in this cell differs from the formulas in this area of the
spreadsheet." Interestingly enough, the same column has one value of
6.02
with the 2nd error message and one value of 6.02 without.

The solution to this whole formatting mess may be to format all numbers
as
text and let the user format them to be numeric if that's needed.

I know this is a bunch of questions. Thanks for your time.
Scott






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Programmatically create button on Excel worksheet (vb.net) valerashylin Excel Programming 2 March 19th 08 01:27 PM
if i cut and paste from html into excel, i cannot create formulas John Spann Excel Discussion (Misc queries) 8 December 29th 06 02:36 PM
Create programmatically list of combinations for choices from data sets in excel vba somethinglikeant Excel Programming 2 July 9th 06 10:26 PM
From Excel 97 Programmatically create access 97 or 2000 database and export data to. [email protected] Excel Programming 0 December 23rd 04 10:44 PM
Create Excel sheet in HTML with comments Luke Webber Excel Programming 2 October 7th 03 02:34 PM


All times are GMT +1. The time now is 11:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"