i've written this code which will generate an excel spreadsheet and save it to a specified location. I want to then display a "Save as" dialogue box by reading the file from the stored location and then asking then user where they want to store it.
Excel.Application excelApp = null;
Excel.Workbook wb = null;
Excel.Worksheet ws = null;
Excel.Range range = null;
excelApp = new Excel.Application();
wb = excelApp.Workbooks.Add();
ws = wb.Worksheets.get_Item(1) as Excel.Worksheet;
for(int i = 0; i< 10;++i) {
ws.Cells[i, 1] = i+
}
wb.SaveAs(@"C:\test.xls", Excel.XlFileFormat.xlWorkbookNormal);
wb.Close(true);
excelApp.Quit();
How to download in the following format?
string str = "Hello, world";
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(str);
return File(bytes, "text/plain");