How can i display created arraylist in ms excel? Please guide me..
-
Do you need assistance on how to write some value to an excel file?Marco– Marco2011-10-18 08:46:23 +00:00Commented Oct 18, 2011 at 8:46
-
@Marco..ya i created an arraylist but i have to display that arraylist in excel sheet..is it possible?if yes kindly let me know?Satya– Satya2011-10-18 08:47:41 +00:00Commented Oct 18, 2011 at 8:47
Add a comment
|
1 Answer
Add a reference to Microsoft.Office.Interop.Excel assembly.
Then try this (just an idea, not full and perfect code):
using Excel = Microsoft.Office.Interop.Excel;
Excel.Application excel = new Excel.Application();
Excel.Workbook wb = excel.Workbooks.Open("filename");
Excel.Worksheet sh = wb.Sheets[1]; // or wb.Sheets["name"]
int row = 2;
foreach (string item in array)
{
sh.Cells[row,col].Value2 = item;
row++;
}
wb.Save();
wb.Close();
excel.Quit();
5 Comments
Satya
I did :) once again Thanks for the answer Marco :)
Satya
@Marco..Now i need to get a window asking me where to save on disk ?
Marco
@Satya: you have to study a little bit, because this is a really basic action!! Anyway, create a
SaveFileDialog and call it dlgSave and use if (dlgSave.ShowDialog() == DialogResult.OK) dlgSave.Filename...Satya
Marco but the thing is I want Web application not the windows application?savefileDialog is for win app i guess?