Spread for Asp.net在画线是为了避免Border和GridLine之间发生冲突,会将线画的粗一个像素,如果想实现在浏览器中看到的和Excel中看到一样的效果,需要在OpenExcel之后对边线进行重新设置,如果Excel中设置的边线本来就比较复杂,那么重新设置边线的代码就会比较复杂,针对你发来的测试Excel文件可以通过下面的代码来实现:- protected void Open_Click(object sender, EventArgs e)
- {
- FpSpread1.OpenExcel(Server.MapPath("tst1.xls"));
- FarPoint.Web.Spread.SheetView view = FpSpread1.ActiveSheetView;
- for (int i = 0; i < view.RowCount; i++)
- {
- for (int j = 0; j < view.ColumnCount; j++)
- {
- view.Cells[i, j].Border.BorderSizeLeft = 1;
- view.Cells[i, j].Border.BorderSizeTop = 1;
- view.Cells[i, j].Border.BorderSizeRight = 1;
- view.Cells[i, j].Border.BorderSizeBottom = 1;
- }
- }
-
- }
- protected void Save_Click(object sender, EventArgs e)
- {
- FarPoint.Web.Spread.SheetView view = FpSpread1.ActiveSheetView;
- for (int i = 0; i < view.RowCount; i++)
- {
- for (int j = 0; j < view.ColumnCount; j++)
- {
- view.Cells[i, j].Border.BorderSizeLeft = 2;
- view.Cells[i, j].Border.BorderSizeTop = 2;
- view.Cells[i, j].Border.BorderSizeRight = 2;
- view.Cells[i, j].Border.BorderSizeBottom = 2;
- }
- }
- FpSpread1.SaveExcel(Server.MapPath("test.xls"));
- for (int i = 0; i < view.RowCount; i++)
- {
- for (int j = 0; j < view.ColumnCount; j++)
- {
- view.Cells[i, j].Border.BorderSizeLeft = 1;
- view.Cells[i, j].Border.BorderSizeTop = 1;
- view.Cells[i, j].Border.BorderSizeRight = 1;
- view.Cells[i, j].Border.BorderSizeBottom = 1;
- }
- }
- }
复制代码 |