public void initSpread(FarPoint.Web.Spread.FpSpread fpSpread, string sheetName, int rowCount, int columnCount)
{
FarPoint.Web.Spread.SheetView sheet = new FarPoint.Web.Spread.SheetView();
sheet.SheetName = sheetName;
sheet.ColumnCount = columnCount;
sheet.RowCount = rowCount;
sheet.PageSize = rowCount;
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
{
if (rowIndex == 0)
{
sheet.SpanModel.Add(0, 0, 1, columnCount - 1);
sheet.Cells[0, 0, 1, columnCount - 1].Text = "我跨列了!";
sheet.Rows[0].BackColor = Color.Black;
}
else
{
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
{
sheet.Cells[rowIndex, columnIndex].Text = string.Format("r{0}c{1}", rowIndex, columnIndex);
}
}
}
sheet.AllowLoadOnDemand = true;
sheet.AutoCalculation = true;
//设置FrozenColumnCount=1会出现布局混乱的问题
sheet.FrozenColumnCount=1;
sheet.Columns[0].BackColor = Color.Gray;
fpSpread.Sheets.Add(sheet);
} |