asp.net保存Excel文件时文件名的问题
我根据需要将页面中的值保存到excel文件中,在保存时我用excel.saveWorkSpace保存文件,但是文件的默认名怎么改成自己想要的,它默认为Sheet1
着急,大虾们,帮帮忙啊,小弟第一次在csdn里发帖,如有不周还请谅解
------解决方案--------------------設置worksheet.Name = "Sheet名字";如下:
#region 创建Excel及worksheet
ConExcel.Workbooks workbooks = xlApp.Workbooks;
ConExcel.Workbook workbook = workbooks.Add(ConExcel.XlWBATemplate.xlWBATWorksheet);
ConExcel.Range range = null;
ConExcel.Worksheet worksheet = (ConExcel.Worksheet)workbook.Worksheets.get_Item(workbook.Worksheets.Count);
workbook.Worksheets.Add(Type.Missing, worksheet, Type.Missing, Type.Missing);//取得sheet1
worksheet.Name = "Sheet名字";
#endregion
------解决方案--------------------ConExcel.Worksheet worksheet =
worksheet.Name = "Sheet名字"; 1楼正解!