string filePath = AppDomain.CurrentDomain.BaseDirectory + @"datafile emp.xlsx"; System.IO.File.Create(filePath).Close(); //创建一个excel文件 FileStream fs = new FileStream(filePath, FileMode.Open); IWorkbookSet workbookSet = Factory.GetWorkbookSet(); IWorkbook workbook = workbookSet.Workbooks.OpenFromStream(fs); fs.Close(); IWorksheet worksheet = workbook.Worksheets[0]; worksheet.Name = "RFQ Replies"; //为sheet1重命名 IRange cells = worksheet.Cells; cells[0,1].Value = "给第一行第二列的单元格复制" cells[0, 1].ColumnWidth = 70; //列宽 string outputFilePath = AppDomain.CurrentDomain.BaseDirectory + @"datafile"; string singleName = "Excel " + DateTime.Now.ToChinaTime().ToString("dd_MM-yyyy HH_mm") + ".xlsx"; workbook.SaveAs(outputFilePath + singleName, FileFormat.OpenXMLWorkbook);//保存为一个新文件 System.IO.File.Delete(filePath); //删除之前的文件