Excel スプレッドシートを生成し、指定した場所に保存するこのコードを作成しました。次に、保存された場所からファイルを読み取り、ユーザーに保存場所を尋ねて、「名前を付けて保存」ダイアログボックスを表示したいと思います。
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();
次の形式でダウンロードするにはどうすればよいですか?
string str = "Hello, world";
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(str);
return File(bytes, "text/plain");