/// <summary> /// 判断文件是否存在,不存在则创建 /// </summary> /// <param name="fileFullPath">目录名+文件名</param> private void fileExsitOrCreate(string fileFullPath) { if (!File.Exists(fileFullPath)) { ReflectEntityProp <BillForExcel> goodsReflect = new ReflectEntityProp <BillForExcel>(); ReflectEntityProp <GoodsTypeForExcel> goodsTypeReflect = new ReflectEntityProp <GoodsTypeForExcel>(); HSSFWorkbook wb = new HSSFWorkbook(); //格式 ICellStyle style = wb.CreateCellStyle(); style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center; IFont font = wb.CreateFont(); font.IsBold = true; font.FontHeightInPoints = 12; style.SetFont(font); if (ExcelTool.getSheetDataAt(ExcelTool.getWorkBook(filePath + fileName), TableId.BillForExcel.ToString()) == null) { ExcelTool.createExcelColumns <BillForExcel>(ref wb, style); } if (ExcelTool.getSheetDataAt(ExcelTool.getWorkBook(filePath + fileName), TableId.GoodsTypeForExcel.ToString()) == null) { ExcelTool.createExcelColumns <GoodsTypeForExcel>(ref wb, style); } FileStream fs = new FileStream(fileFullPath, FileMode.Create); wb.Write(fs); fs.Close(); } }