Jump to content
  • Advertisement
Sign in to follow this  
Skibula

[.net] how to export my array to Excel file

This topic is 3256 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey all, my question for today is :-) ? how can i export my array into excel file lets say i got array of points so x,y arr[0] point (1,3) arr[1] point (2,4) (its just an exemple) how can i export this array into excel file i want to get something like that 2a81d87.jpg http://tinypic.com/r/2a81d87/3 the idea is that the user will change information on the array (stuff that i need to do) then i can export it to excel so i can use that excel file for more stuff im using C# on windows forms

Share this post


Link to post
Share on other sites
Advertisement
You have to write a csv file. CSV files are text files with a very simple structure. Each line represents one row and each column is separated with ','. Your file would look like

,x,y
arr[0],1,3
arr[1],2,4

Btw. your files has to end with '.csv'.

--
Ashaman

Share this post


Link to post
Share on other sites
A CSV file just has rows of data stored in lines, with a comma delimiting (between) each field.

using (var CsvWriter = new StreamWriter("filename.csv")) {
// Write the first line of the CSV file (this contains the column headers):
CsvWriter.WriteLine(",x,y");
// Write the data lines to the CSV file:
for (int i = 0; i < arr.Length; ++i) {
CsvWriter.WriteLine("arr[{0}],{1},{2}", i, arr.X, arr.Y);
}
}

Share this post


Link to post
Share on other sites
ok thanks alot i will try that

so i guess i use stream reader to read from csv file

how i can read array of points in that way

i mean

how i know when to stop to read?
when its the X and when its Y

so hard :-(

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!