Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2007

Tip: Looking for answers? Try searching our database.

Creating Excel file from other program

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonas Bergman - 23 Jan 2007 10:49 GMT
Hi

I would like to create an excel file from another program, without using
Excel Interop.

I have created files like that before using tab separated text files with
the .xls-extension. Works fine, but....

This time I need to create a simple Excel file that contains two or more
sheets. Does anyone have an idea??

No formatting needed, just the plain data.

/Jonas
Harlan Grove - 23 Jan 2007 19:36 GMT
Jonas Bergman wrote...
...
>I would like to create an excel file from another program, without using
>Excel Interop.
[quoted text clipped - 6 lines]
>
>No formatting needed, just the plain data.

Why create XLS files? They're a major PITA to get right. If the only
functionality you need beyond plain text files is multiple worksheets,
create XML files. Here's an example layout with interspersed comments.
Lines in the XML file are indented 2 spaces, and none of the lines
should wrap. Comments are flush with the left margin.

 <?xml version="1.0"?>
 <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet">

This seems to be all that's needed from the opening Workbook tag Excel
itself generates when saving workbooks as XML files.

  <Worksheet ss:Name="Sheet1">
   <Table>
    <Row>
     <Cell><Data ss:Type="Number">1</Data></Cell>
     <Cell><Data ss:Type="String">a</Data></Cell>
    </Row>
    <Row>
     <Cell><Data ss:Type="Number">2</Data></Cell>
     <Cell><Data ss:Type="String">b</Data></Cell>
    </Row>
    <Row>
     <Cell><Data ss:Type="Number">3</Data></Cell>
     <Cell><Data ss:Type="String">c</Data></Cell>
    </Row>
    <Row>
     <Cell><Data ss:Type="Number">4</Data></Cell>
     <Cell><Data ss:Type="String">d</Data></Cell>
    </Row>
   </Table>
  </Worksheet>

This is the first worksheet section. Data appears by row, then by cell
within row. I deleted the parameters in the beginning Table tag. They
don't appear to be necessary.

  <Worksheet ss:Name="Sheet2">
   <Table>
    <Row>
     <Cell><Data ss:Type="String">foo</Data></Cell>
     <Cell><Data ss:Type="String">bar</Data></Cell>
     <Cell><Data ss:Type="Number">1</Data></Cell>
     <Cell><Data ss:Type="String">doda</Data></Cell>
     <Cell><Data ss:Type="String">day</Data></Cell>
     <Cell><Data ss:Type="Number">2</Data></Cell>
    </Row>
   </Table>
  </Worksheet>

This is the second worksheet section.

 </Workbook>

And this is the end tag for the workbook. That's all there is.

Note: the ss:Type parameters in the Data tags are necessary.

When opened in Excel, the XML file above produces a workbook with two
worksheets, the first named A containing

1    a
2    b
3    c
4    d

and the second named B containing

foo    bar    1    doda    day    2

Generating such pure data XML files would be MUCH, MUCH easier than
generating XLS files.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.