/// <summary> /// 临时保存 /// </summary> /// <returns></returns> private string TemporarySave() { string _path = AppDomain.CurrentDomain.BaseDirectory; _path += string.Format(@"\TemporarySave{0}.xls", DateTime.Now.ToString("hhmmss")); using (FileStream file = new FileStream(_path, FileMode.Create)) { HssfWork.Write(file); file.Close(); } return(_path); }
/// <summary> /// 设置Excel行 /// </summary> private void SetExcelTitle(Dictionary <PropertyInfo, ExcelInfoAttribute> excelInfos) { IRow rowTitle = HssfSheet.CreateRow(0); int _cellIndex = 0; ICellStyle cellStyle = HssfWork.CreateCellStyle(); cellStyle = StyleMessage.GetCellStyle(HssfWork, ExcelStyle.title); foreach (var item in excelInfos) { ICell celltitle = rowTitle.CreateCell(_cellIndex); celltitle.SetCellValue(item.Value.Name); celltitle.CellStyle = cellStyle; HssfSheet.SetColumnWidth(_cellIndex, item.Value.Width); _cellIndex++; } }