foreach (FarPoint.Web.Spread.Row r in FpSpread1.Sheets[0].Rows)
{
//获取计量单位,以便格式转换
string data_unit;
data_unit = Convert.ToString(FpSpread1.ActiveSheetView.GetValue(r.Index, 7));
foreach (FarPoint.Web.Spread.Column c in FpSpread1.Sheets[0].Columns)
{
if (c.DataField == "lst_id")
{
c.Visible = false;
}
else
{
if (list.Contains(c.DataField))
{
farmat_celltype(data_unit, r.Index, c.Index);
}
}
}
}
protected void farmat_celltype(string data_unit,int row ,int col)
{
if (data_unit == "%")
{
FarPoint.Web.Spread.PercentCellType Per_Cell = new FarPoint.Web.Spread.PercentCellType();
//c.CellType = Per_Cell;
FpSpread1.ActiveSheetView.Cells[row, col].CellType = Per_Cell;
}
else
{
FarPoint.Web.Spread.DoubleCellType dou_Cell = new FarPoint.Web.Spread.DoubleCellType();
FpSpread1.ActiveSheetView.Cells[row, col].CellType = dou_Cell;
}
}
、、、、、、、、、、、、、、、、、、、、一下是导出:
FpSpread1.SaveExcelToResponse(Server.UrlEncode("导出信息") + DateTime.Now.ToString("yyyymmdd") + ".xls", FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders); |
|