To create such spreadsheet you have to do a lot of formatting at runtime. The best way to fill the spread with the data would be to execute a Union SQL command on your database. If that option is not available then you may apply the approach I explained earlier. Below is the sample code that will provide some similar behaviour:
//create Asset DataTable and add columns and rows
DataTable Assets = new DataTable();
Assets.Columns.Add("Items", typeof(string));
Assets.Columns.Add("Amount", typeof(decimal));
Assets.Rows.Add(new object[] { "Cash", 15300 });
Assets.Rows.Add(new object[] { "Land", 10 });
//create Liabilities DataTable and add columns and rows
DataTable Liabilities = new DataTable();
Liabilities.Columns.Add("Items", typeof(string));
Liabilities.Columns.Add("Amount", typeof(decimal));
Liabilities.Rows.Add(new object[] {"Equity",600});
Liabilities.Rows.Add(new object[] {"Capital",512});
//Bind the spread to Assets
FpSpread1.ActiveSheetView.DataSource = Assets;
FpSpread1.ActiveSheetView.DataMember = "Assets";
//get the reference of DefaultSheetDataModel
FarPoint.Web.Spread.Model.DefaultSheetDataModel dm = (FarPoint.Web.Spread.Model.DefaultSheetDataModel)FpSpread1.ActiveSheetView.DataModel;
//add header rows
dm.AddUnboundRows(0, 1);
dm.SetValue(0, 0, "ASSETS");
dm.SetValue(0, 1, "AMOUNT");
int addRowIndex=dm.RowCount;
dm.AddUnboundRows(addRowIndex, 1);
dm.SetValue(addRowIndex, 0, "LIABILITIES");
dm.SetValue(addRowIndex, 1, "AMOUNT");
//Append the rows from Liabilities DataTable
addRowIndex = dm.RowCount;
dm.AddRows(addRowIndex, Liabilities.Rows.Count);
foreach (DataRow r in Liabilities.Rows)
{
dm.SetValue(addRowIndex, 0, r[0]);
dm.SetValue(addRowIndex, 1, r[1]);
addRowIndex++;
}
Regards,
Scott S.
Product Manager, Spread ASP.NET
GrapeCity FarPoint