回复 2楼iceman的帖子
仅是导入操作,使用的代码:
- FarPoint.Web.Spread.FpSpread spread = new FarPoint.Web.Spread.FpSpread();
- spread.OpenExcel(ExcelPath);
复制代码
其他的就是给Spread添加一些预渲染的边框样式和允许删除行列的行为属性了:
- void ReportTemplate_PreRender(object sender, EventArgs e)
- {
- FpSpread spread = (FpSpread)sender;
- System.Web.UI.Page page = spread.Page;
- if (page != null)
- {
- //定义表单样式
- spread.ActiveSheetView.TitleInfo.BackColor = Color.Silver;
- string imageUrl = VirtualPath.GetVirtualPath() + "/Content/images/spread/gradient1_ch.gif";
- spread.ActiveSheetView.ColumnHeader.DefaultStyle.Background.BackgroundImageUrl = imageUrl;
- spread.ActiveSheetView.RowHeader.DefaultStyle.Background.BackgroundImageUrl = imageUrl;
- spread.ActiveSheetView.SheetCorner.DefaultStyle.Background.BackgroundImageUrl = imageUrl;
- spread.CommandBar.Visible = false;
- spread.Height = new Unit("100%");
- spread.Width = new Unit("100%");
- FarPoint.Web.Spread.TextCellType textType = new FarPoint.Web.Spread.TextCellType();
- spread.ActiveSheetView.DefaultStyle.CellType = textType;
- spread.ActiveSheetView.DefaultStyle.HorizontalAlign = HorizontalAlign.Left;
- spread.ActiveSheetView.DefaultStyle.Font.Size = FontUnit.Point(12);
- //边框样式
- spread.BorderColor = Color.Silver;
- spread.BorderStyle = BorderStyle.None;
- spread.BorderWidth = 0;
- FarPoint.Web.Spread.Border border = new FarPoint.Web.Spread.Border();
- border.BorderStyle = BorderStyle.Solid;
- border.BorderColor = Color.Silver;
- border.BorderSize = 1;
- spread.ActiveSheetView.DefaultStyle.Border = border;
- spread.ActiveSheetView.GridLineColor = Color.Silver;
- //---------------允许行为------------------------
- spread.HorizontalScrollBarPolicy = FarPoint.Web.Spread.ScrollBarPolicy.Always;
- spread.VerticalScrollBarPolicy = FarPoint.Web.Spread.ScrollBarPolicy.Always;
- //列可以拖拽
- spread.ActiveSheetView.AllowColumnMove = true;
- //可以删除行
- spread.ActiveSheetView.AllowDelete = true;
- //可以删除列
- spread.ActiveSheetView.AllowInsert = true;
- spread.ActiveSheetView.AllowSort = false;
- spread.ClientAutoCalculation = true;
- spread.EditModeReplace = true;
- spread.ActiveSheetView.AllowPage = false;
- spread.AllowHeaderResize = true;
- spread.ActiveSheetView.AllowLoadOnDemand = true;
- spread.ShowFocusRectangle = true;
- spread.Attributes.Add("onkeydown", "cellInput()");
- spread.UseClipboard = false;
- }
- }
复制代码
1、使用我发excel,不编辑,直接导入会很慢;
2、用excel2007打开再关闭,提示是否重新计算公式,点“是”,此时在导入就很顺畅了;
3、若是打开后直接另存为xlsx格式,导入时依然很慢。
是不是原excel文档是老版excel编辑时使用旧的excel计算公式方法所导致的? |