This shows the basics of saving information to an Excel workbook. You just need to modify it to your own specific requirements. If you do not want column headers then just omit the first loop, and leave the row number equal to 1.
using Excel = Microsoft.Office.Interop.Excel;
void Save()
{
Excel.Application excelApp = new Excel.Application();
Excel.Workbook excelWorkBook = excelApp.Workbooks.Add(Type.Missing);
Excel.Worksheet excelWorkSheet = excelWorkBook.Sheets.Add(Type.Missing);
excelWorkSheet.Name = "mydata";
int row = 1;
int column = 1;
for
{
excelWorkSheet.Cells[row, column] =
++column;
}
int row = 2;
foreach (string str in
{
string[] fields = str.Split(new char[]{ '@', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
for (column = 0; column < fields.length; ++column)
{
excelWorkSheet.Cells[row, column + 1] = fields[column];
}
row++;
}
excelWorkBook.SaveAs(fileName);
excelWorkBook.Close();
excelApp.Quit();
}