i am able to create an excel file by using this:
protected void excldwnlbtn4_Click(object sender, EventArgs e)
{
write_on_excel();
}
public void write_on_excel()
{
Excel.ApplicationClass excelApp = new Excel.ApplicationClass();
try
{
Excel.Workbook workbook = (Excel.Workbook)excelApp.Workbooks.Add(Missing.Value);
Excel.Worksheet worksheet;
// Get first Worksheet
worksheet = (Excel.Worksheet)workbook.Sheets.get_Item(1);
// Setting cell values
((Excel.Range)worksheet.Cells[1, "A"]).Value2 = "Vendor Code";
((Excel.Range)worksheet.Cells[1, "B"]).Value2 = "Vendor Password";
((Excel.Range)worksheet.Cells[1, "C"]).Value2 = "Vendor Name";
workbook.Save();
workbook.Close(0, 0, 0);
}
catch (Exception)
{
lblmsg4.Text = "File not Downloaded!!";
}
finally
{
excelApp.Quit();
}
}
by this i am creating a .xlsx file in my c:\documents as book1.xlsx but i want to specify the folder path and file name how can i do this?
Use a Save As