我正在使用 ExcelLibrary 生成动态 Excel 表。效果很好。
代码
//create new xls file
string file = Server.MapPath("Discussion_Board_Report.xls");
Workbook workbook = new Workbook();
Worksheet worksheet = new Worksheet("Report");
worksheet.Cells[0, 0] = new Cell("COMM 226 Case Discussions Report");
worksheet.Cells[4, 0] = new Cell("Student ID");
worksheet.Cells[4, 1] = new Cell("User Name");
worksheet.Cells[4, 2] = new Cell("Case 1");
worksheet.Cells[4, 3] = new Cell("Case 2");
worksheet.Cells[4, 4] = new Cell("Case 3");
worksheet.Cells[4, 5] = new Cell("Topics");
worksheet.Cells[4, 6] = new Cell("Replies");
workbook.Worksheets.Add(worksheet);
workbook.Save(file);
问题
这段代码的问题是,它将文件保存在服务器中。我无法在 C:// 中保存文件,因为 Windows 想要允许我在未经用户许可的情况下保存!我希望用户选择自己的文件路径。如何提示另存为对话框?