建议使用Aspose.Cells,使用很方便!
Workbook workbook = new Workbook(); //工作簿
Worksheet sheet = workbook.Worksheets[0]; //工作表
Cells cells = sheet.Cells; //单元格
//中间省略
string sDir = HttpContext.Current.Request.PhysicalApplicationPath + "UpLoad\\"; //文件上传路径
if (!Directory.Exists(sDir))
{
Directory.CreateDirectory(sDir);
}
DateTime datedt = DateTime.Now;
string strdate = datedt.ToString("yyyyMMddmmhhss");
string savePath = sDir + "统计报表" + strdate + ".xlsx";
string returnPath = "..//UpLoad//统计报表" + strdate + ".xlsx";
workbook.Save(savePath);