使用FpSpread1.OpenExcel()方法将Exelc文档内容导入到spread表格中不能修改单格的宽度和类型
【页面效果图】
----------------------------------------------------------------后台代码-----------------------------------------------------------------------------
/// <summary>
/// 导入Execl
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnUpload_Click(object sender, EventArgs e)
{
string returnMsg = string.Empty;
string savePath = Server.MapPath("~/UploadFiles");
if (!System.IO.Directory.Exists(savePath))
{
System.IO.Directory.CreateDirectory(savePath);
}
if (this.FileUpload1.HasFile)
{
string TimeName = DateTime.Now.ToString("yyyyMMddhhmmssff");
string filename = this.FileUpload1.FileName;
string filetype = filename.Substring(filename.LastIndexOf("."));
string ServerFilePath = savePath + "\\" + filetype.Replace(filetype, "") + TimeName + filetype;
FileUpload1.SaveAs(ServerFilePath);
this.FpSpread1.OpenExcel(ServerFilePath, FarPoint.Excel.ExcelOpenFlags.TruncateEmptyRowsAndColumns);
//Response.Redirect("TwoSpread.aspx?ServerFilePath=" + ServerFilePath);
this.FpSpread1.OpenExcel(ServerFilePath, FarPoint.Excel.ExcelOpenFlags.TruncateEmptyRowsAndColumns);
// 取消分页
foreach (SheetView sheet in this.FpSpread1.Sheets)
{
sheet.AllowPage = false;
}
int count = this.FpSpread1.Sheets.RowCount;
//// 设置复选框主
this.FpSpread1.Sheets.Columns.CellType = new FarPoint.Web.Spread.CheckBoxCellType();
//// 设置Spread表格的行数和例数
this.FpSpread1.Sheets.ColumnCount = 100;
this.FpSpread1.Sheets.RowCount = 100;
this.FpSpread1.Sheets.Columns.Width = 50;
this.FpSpread1.Sheets.Columns.Width = 120;//设置项目例的宽度
this.FpSpread1.Sheets.Columns.Width = 120;//所属部门
this.FpSpread1.Sheets.Columns.Width = 120;//预算事项编码
this.FpSpread1.Sheets.Columns.Width = 120;//预算事项名称
this.FpSpread1.Sheets.Columns.Width = 120;//预算科目代码
this.FpSpread1.Sheets.Columns.Width = 120;//预算科目名称
this.FpSpread1.Sheets.Columns.Width = 50; //年度
}
}
--------------------------------------------------------------------------------------------------------------------------------------------- 控制Spread为只读:
FpSpread1.Sheets.OperationMode = FarPoint.Web.Spread.OperationMode.ReadOnly;
页:
[1]