I want to fill the data from datagrid control of vb.net in xls file. Please suggest some code to fill xls from datagrid, not with dataset as I can't because I am filling gridview using some other tool.
vb.net datagrid to xls
Collapse
X
-
What other tool are you using?Originally posted by Garima12I want to fill the data from datagrid control of vb.net in xls file. Please suggest some code to fill xls from datagrid, not with dataset as I can't because I am filling gridview using some other tool. -
can you post help regarding creating csv file?
Originally posted by PlaterDon't DataTable and DataSets have a WriteXML() and WriteXmlSchema( ), could those be used to help?
I don't think there is a native way in .NET to create an excel file.
You could make a CSV pretty easy from it though.Comment
-
Loop through your data, each row is a line, each column gets a comma between it.
If there are commas in your data, wrap the whole thing in quotes.
If there are quotes in you data, wrap it in double quotes.
Check the internet for more CSV rules.Comment
-
There may be no native way, but there is a way using Interop.Originally posted by PlaterDon't DataTable and DataSets have a WriteXML() and WriteXmlSchema( ), could those be used to help?
I don't think there is a native way in .NET to create an excel file.
You could make a CSV pretty easy from it though.
It's fairly simple. You need to include System.IO, and then just create the file:Originally posted by Garima12can you post help regarding creating csv file?
And follow Plater's advice, find out more on rules of CSVs.Code:FileStream fs = new FileStream(@"c:\dev\test.csv", FileMode.Create); StreamWriter sw = new StreamWriter(fs); ///////// //This section: replace. Loop through your data, inserting commas between columns and newlines between rows. sw.WriteLine("name,number"); sw.WriteLine("Curtis,10"); ///////// sw.Close(); fs.Close(); //always close your streamsComment
Comment