日期:2014-05-18  浏览次数:21024 次

gridcontrol导出报表
gridcontrol点击导出excel数据导出来。然后点击保存按钮。怎么弹出对话框让用户选择路径进行保存

------解决方案--------------------
导出时用一个saveFileDialog,将选择路径传到下面方法就可以了

public static void ExportPurchaseProductExcel(DataTable table, string templetPath, string savePath)
{
导出时加上这句代码
File.Copy(templetPath, savePath, true);//模版路径,保存路径
_Excel.Application app = new _Excel.ApplicationClass();
app.Visible = false;
_Excel.Workbook book = app.Workbooks.Open(savePath, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing);
_Excel.Worksheet sheet = (_Excel.Worksheet)book.ActiveSheet;