private bool CreateAssetSheet(int group_index, ref DataTable table) { bool result = false; System.Web.UI.HtmlTextWriter _writer = GetWriter(); if ((table != null) && (_writer != null)) { string expression = "GroupId=" + group_index.ToString(); DataRow[] foundRows = null; foundRows = table.Select(expression); ExcelColumns columns = null; if (foundRows != null) { if (foundRows.Length > 0) { result = true; DataRow _init = foundRows[0]; if (_init != null) { int _asset_type_id = Int32.Parse(_init["AssetTypeId"].ToString()); int _department_id = Int32.Parse(_init["DepartmentId"].ToString()); columns = CreateColumns(ref columns, ref table); if (columns != null) { DataTable _custom_properties_table = GetAssetProperties(_department_id, _asset_type_id); if (_custom_properties_table != null) { foreach (DataRow _row in _custom_properties_table.Rows) { if (_row != null) { string _property_name = _row["Name"].ToString(); int _property_type = Int32.Parse(_row["DataType"].ToString()); string _system_type = "System.String"; switch (_property_type) { case 0: _system_type = "System.String"; break; case 1: _system_type = "System.Int32"; break; case 2: _system_type = "System.Decimal"; break; case 3: _system_type = "System.DateTime"; break; case 4: _system_type = "System.String"; break; } columns = AddColumn(ref columns, _property_name, _system_type); } } } } } } else return false; } else return false; int _sheet_id = group_index + 1; string _sheet_name = "AssetsGroup" + _sheet_id.ToString(); string _start_worksheet = "<Worksheet ss:Name=\"" + _sheet_name + "\">"; string _end_worksheet = "</Worksheet>"; _writer.Write(_start_worksheet); ExcelTable _table = this.CreateWorkSheet(_sheet_name, ref columns); if (_table != null) { AddHeader(ref _table, ref columns); //***new _writer.Write(_table.ToHeader()); bool is_white = true; DataTable _custom_properties_full = null; for (int row_index = 0; row_index < foundRows.Length; row_index++) { DataRow _row = foundRows[row_index]; if (_row != null) { //***ExcelRow excel_row = AddRow(row_index + 1, ref _table); ExcelRow excel_row = new ExcelRow(_table); if (excel_row != null) { UpdateRow(ref excel_row, ref table, ref _row, is_white); int _department = Int32.Parse(_row["DepartmentId"].ToString()); int _asset_id = Int32.Parse(_row["Id"].ToString()); int _asset_type_id = Int32.Parse(_row["AssetTypeId"].ToString()); if (_custom_properties_full == null) _custom_properties_full = GetAssetProperties(_department, _asset_type_id); DataTable _custom_properties = GetAssetPropertyValues(_department, _asset_id, _asset_type_id); UpdateRow(ref excel_row, ref _custom_properties_full, ref _custom_properties, "Name", "PropertyValue", is_white); if (is_white) is_white = false; else is_white = true; //***new _writer.Write(excel_row.ToString()); _writer.Flush(); } } } //***new _writer.Write(_table.ToFooter()); } _writer.Write(_end_worksheet); } return result; }