0

How can i display created arraylist in ms excel? Please guide me..

2
  • Do you need assistance on how to write some value to an excel file? Commented 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? Commented Oct 18, 2011 at 8:47

1 Answer 1

1

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();
Sign up to request clarification or add additional context in comments.

5 Comments

I did :) once again Thanks for the answer Marco :)
@Marco..Now i need to get a window asking me where to save on disk ?
@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...
Marco but the thing is I want Web application not the windows application?savefileDialog is for win app i guess?
@Satya: check this link: it's in italian, but solutions is there

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.