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()
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()
easiest way to work with Excel in .NET is by using 3rd party component. You can try GemBox.Spreadsheet - Excel component for .NET that is free to use if you have files smaller then 150 rows.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.