想到一个笨方法解决自己的问题,就是在导出pdf前,先将grid的字体调小,让cell的内容不会被切掉,导出pdf后,马上把grid字体调回原本设定,这样既可以符合需求,也不会影响到web浏览时的字体大小
// 导出pdf前,先設定grid字型大小,讓同一row可以同一頁顯示,cell资料也可以完全显示
FpSpread1.Sheets[0].DefaultStyle.Font.Size = 7;
FpSpread1.Sheets[0].ColumnHeader.DefaultStyle.Font.Size = 7;
FpSpread1.Sheets[0].RowHeader.DefaultStyle.Font.Size = 7;
for (int sCol = 0; sCol < (int)FP1_COL.COLCOUNT; sCol++)
{
switch (sCol)
{
default:
FpSpread1.Sheets[0].Columns[sCol].Font.Size = 7;
break;
}
}
//导出pdf
FarPoint.Web.Spread.PrintInfo pi;
pi = new FarPoint.Web.Spread.PrintInfo();
pi.Orientation = FarPoint.Web.Spread.PrintOrientation.Landscape;
pi.SmartPrintPagesTall = 1;
pi.SmartPrintPagesWide = 1;
pi.ZoomFactor = 0.8f;
FpSpread1.ActiveSheetView.PrintInfo = pi;
this.FpSpread1.SavePdf(this.FpSpread1.Sheets[0], FILEPATH);
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, typeof(UpdatePanel), "openfiles", "window.open('" + fileName + "')", true);
//导出pdf后,再把grid字體調回原始設定
FpSpread1.Sheets[0].DefaultStyle.Font.Size = 10;
FpSpread1.Sheets[0].ColumnHeader.DefaultStyle.Font.Size = 10;
FpSpread1.Sheets[0].RowHeader.DefaultStyle.Font.Size = 10;
for (int sCol = 0; sCol < (int)FP1_COL.COLCOUNT; sCol++)
{
switch (sCol)
{
default:
FpSpread1.Sheets[0].Columns[sCol].Font.Size = 10;
break;
}
} |