Пример #1
0
 public static void DataToColumnHead(DataRow[] drs, Worksheet sheet, int StartRow, int StartCol, int ColHeight, int ColWidth, string[,] Fields, ref int RowNum)
 {
     if ((drs.Length != 0) && (Fields != null))
     {
         int num    = StartRow;
         int num2   = StartCol;
         int length = drs.Length;
         for (int i = 0; i < length; i++)
         {
             DataRow dr = drs[i];
             for (int j = 0; j < ColHeight; j++)
             {
                 for (int k = 0; k < ColWidth; k++)
                 {
                     string columnName = Fields[j, k];
                     if ((columnName != null) && (columnName.Trim() != ""))
                     {
                         Excel.Range range = TExcel.GetCell(sheet, num + j, num2 + k);
                         try
                         {
                             string str;
                             if (((str = columnName.ToUpper()) != null) && (string.IsInterned(str) == "@@ROWNUM"))
                             {
                                 RowNum++;
                                 range.Value = (int)RowNum;
                             }
                             else
                             {
                                 range.Value = TExcel.GetItemValue(dr, columnName, false);
                             }
                         }
                         catch
                         {
                         }
                         finally
                         {
                             TExcel.DisposeObject(range);
                         }
                     }
                 }
             }
             num2 += ColWidth;
         }
     }
 }