回复 18楼langren82的帖子
浏览器渲染方式可能和 Excel不同,请尝试在导出之前设置 BorderSize 为 2,导出之后重置为 1:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- {
- return;
- }
- SetCellBorder(2);
- FpSpread1.SaveExcel(this.Server.MapPath("test.xls"), FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders | FarPoint.Excel.ExcelSaveFlags.SaveAlternatingRowStyles | FarPoint.Excel.ExcelSaveFlags.SaveAsViewed);
- SetCellBorder(1);
- }
- private void SetCellBorder(int width)
- {
- int rowcount = this.FpSpread1.Sheets[0].RowCount;
- int colcount = this.FpSpread1.Sheets[0].ColumnCount;
- for (int i = 0; i < rowcount; i++)
- {
- for (int j = 0; j < colcount; j++)
- {
- this.FpSpread1.ActiveSheetView.Cells[i, j].Border.BorderStyle = BorderStyle.Solid;
- this.FpSpread1.ActiveSheetView.Cells[i, j].Border.BorderSize = width;
- this.FpSpread1.ActiveSheetView.Cells[i, j].Border.BorderColor = System.Drawing.Color.Black;
- }
- }
- }
复制代码 |