writing xls files

p4p800

Member
Joined
Mar 2, 2004
Messages
10
i want this to have two columns in excel can i do that


Code:
Dim writer As New System.IO.StreamWriter("test.xls")
        writer.Write(ComboBox1.Items(0))
        writer.Write(ComboBox1.Items(1))
        writer.WriteLine(a)
        writer.WriteLine(b)
        writer.Flush()
        writer.Close()
 
Im sure Excel format is much more complicated than that so I think that wont work.
 
Last edited by a moderator:
The easiest way would probably be to add the Reference to the MS Excel ##.# library, create your workbooks and worksheets through code, or somehow, and then use Excel library methods to save an excel .Xls spreadsheet file. :)
 
If you dont care about formatting, you can write a file in CSV (Comma Separated Values) format. This involves placing a comma between each column and surrounding each column with "". End each row with a new line.

CSV files will open in Excel - Excel is the default program associated with them.

Code:
Dim writer As New System.IO.StreamWriter("test.xls")
writer.Write("""" & ComboBox1.Items(0) & """,")
writer.Write("""" & ComboBox1.Items(1) & """")
writer.WriteLine()
writer.Close()
 
Back
Top