先在spread控件中打开excel模板
string strFullName = Environment.CurrentDirectory + "\\" + "template.xls";
fpSpread2.OpenExcel(strFullName, ExcelOpenFlags.TruncateEmptyRowsAndColumns);
对数据进行更新后,spread控件上格式都正常,有黑体字,背景颜色等。
但是使用如下代码保存为excel之后,格式都消失了
string strFile;
SaveFileDialog dlgSaveFile = new SaveFileDialog();
dlgSaveFile.InitialDirectory = "c:\\";
dlgSaveFile.Filter = "Excel 工作簿(*.xlsx)|*.xlsx";
dlgSaveFile.FilterIndex = 1;
dlgSaveFile.FileName = "1.xls";
dlgSaveFile.CheckPathExists = true;
if (dlgSaveFile.ShowDialog() == DialogResult.OK)
{
strFile = dlgSaveFile.FileName;
fpSpread2.SaveExcel(strFile, FarPoint.Excel.ExcelSaveFlags.UseOOXMLFormat);
}
第二个问题是打印问题,打印预览直接多了"/sn"
fpSpread2.Sheets[0].PrintInfo.Preview = true;
fpSpread2.PrintSheet(0);
|