| | |
Import data from .csv and save in separate sheet in .xls
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 89
Reputation:
Solved Threads: 7
Hi,
I have my own dataset of data. Just wonder what function can I use to write into a excel file. For my current coding, I'm writing the data into several .csv files. Now I'm trying to write all these data into separate sheets in excel (.xls). Here my old piece of coding (store data in csv format):
I have my own dataset of data. Just wonder what function can I use to write into a excel file. For my current coding, I'm writing the data into several .csv files. Now I'm trying to write all these data into separate sheets in excel (.xls). Here my old piece of coding (store data in csv format):
C# Syntax (Toggle Plain Text)
StreamWriter writer = File.CreateText(strDirectory + FileName); writer.WriteLine(); writer.WriteLine("Sheet Name"); writer.WriteLine(); writer.WriteLine("Column 1,Column 2, Column 3, Column 4"); foreach (DataRow dr in dtable.Rows) { writer.Write(dr[0]); writer.Write(","); writer.Write(dr[1]); writer.Write(","); writer.Write(dr[2]); writer.Write(","); writer.Write(dr[3]); writer.WriteLine(); }
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
Well csv format (which you're writing out, and theres a quicker way to do that, look at the join function) cannot do multiple excel sheets, the only thing that does multiple sheets is excel. For which you would need to use the excel object.
Take a look, theres been some posts in here about working with excel direct.
Take a look, theres been some posts in here about working with excel direct.
![]() |
Other Threads in the C# Forum
- Previous Thread: C# Help! Arrays, ListBox's and Buttons
- Next Thread: Overload Constructer Using Arrays
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access algorithm array barchart bitmap box buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees draganddrop drawing encryption enum event excel file files form format forms ftp function gdi+ httpwebrequest image index input install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml







