Exemplo n.º 1
0
        public void WriteHeader(int colIndex, int rowIndex, clsExcelWrittingMap writtingMap)
        {
            Dictionary<string, structExcelWrittingInfo> writtingMappingTable = writtingMap.MapTable;

            foreach (string key in writtingMappingTable.Keys)
            {
                int addedColIndex = writtingMappingTable[key].ColumnIndex;
                string fieldNameInExcel = writtingMappingTable[key].WriteName;

                WriteCell(GetExcelAddress(colIndex + addedColIndex, rowIndex), fieldNameInExcel);
            }
        }
Exemplo n.º 2
0
        public void WriteDataTable(int colIndex, int rowIndex, System.Data.DataTable dt, 
            bool isWriteColumnHeader, clsExcelWrittingMap writtingMap, string addedPrefix)
        {
            int addedRowIndex = 0;

            Dictionary<string, structExcelWrittingInfo> writtingMappingTable = writtingMap.MapTable;

            if (isWriteColumnHeader)
            {
                foreach (DataColumn col in dt.Columns)
                {
                    if (writtingMappingTable.ContainsKey(col.ColumnName))
                    {
                        int addedColIndex = writtingMappingTable[col.ColumnName].ColumnIndex;
                        string fieldNameInExcel = writtingMappingTable[col.ColumnName].WriteName;

                        WriteCell(GetExcelAddress(colIndex + addedColIndex, rowIndex + addedRowIndex), fieldNameInExcel);
                    }
                }

                addedRowIndex++;
            }

            foreach (DataRow row in dt.Rows)
            {
                foreach (DataColumn col in dt.Columns)
                {
                    if (writtingMappingTable.ContainsKey(col.ColumnName))
                    {
                        int addedColIndex = writtingMappingTable[col.ColumnName].ColumnIndex;
                        string writeValue = row[col.ColumnName].ToString();

                        WriteCell(GetExcelAddress(colIndex + addedColIndex, rowIndex + addedRowIndex), addedPrefix + writeValue);
                    }
                }

                addedRowIndex++;
            }
        }