我的想法是:使用excel文件(如报告模板),并将此文件保留在源文件/MyProjectFolder/File/Filename.xlsx
中,当用户单击Web中的下载按钮时,他们将使用我的模板创建一个新文件并保存在自己的文件中电脑。
我的代码是:
// Copy template file
Excels.Application excel = new Excels.Application();
Excels.Workbook currWB = excel.Workbooks.Open(pathFile, 0, true, 1, "", "", false, Excels.XlPlatform.xlWindows, 9, false, false, 0, true, false, false);
Excels.Worksheet currWS = currWB.Sheets[1];
currWS.UsedRange.Copy(Type.Missing);
// Paste in new virtual file
Excels.Workbook destWB = excel.Workbooks.Add();
Excels.Worksheet destWS = destWB.Sheets[1];
destWS.UsedRange.PasteSpecial(Excels.XlPasteType.xlPasteAll,Excels.XlPasteSpecialOperation.xlPasteSpecialOperationNone, Type.Missing, Type.Missing);
// Close template file
excel.DisplayAlerts = false;
currWB.Close(false);
/// <summary>
/// Edit virtual file
/// </summary>
// Open dialog choose folder
// Save virtual file
destWB.SaveAs(destinationPath, Type.Missing, Type.Missing, Type.Missing, false, false, Excels.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
我现在的问题是如何打开一个对话框来选择destinationPath
,由于我正在使用WebService
有人可以帮我吗?