コード例 #1
0
ファイル: ExcelBaseDet.cs プロジェクト: OSRS/Oncor_Base
        internal static List <string> Headers(XlWorksheet worksheet)
        {
            List <string> headers = new List <string>();
            IXlRowData    row     = worksheet.Rows[0];

            foreach (IXlCell o in row)
            {
                headers.Add(o.CellValue);
            }
            return(headers);
        }
コード例 #2
0
ファイル: XlWorksheet.cs プロジェクト: OSRS/Oncor_Base
        private void FillRow(Dictionary <string, string> row, List <string> headers, IXlRowData dataRow)
        {
            //List<IXlCell> headers = new List<IXlCell>(headerRow); //this is a waste
            List <IXlCell> values    = new List <IXlCell>(dataRow);
            int            numValues = Math.Min(headers.Count, values.Count); //in case they don't match

            for (int index = 0; index < numValues; index++)
            {
                row[headers[index]] = values[index].CellValue; //note that if there's multiple columns with same name this gets last value for that name
            }
        }
コード例 #3
0
ファイル: XlWorkbook_Save.cs プロジェクト: OSRS/Oncor_Base
        private static void AddRow(IXlRowData rowData, SheetData sheetData, XlSharedStringsTable stringsTable, int rowIndex)
        {
            int columnIndex = 1;
            Row row         = new Row()
            {
                RowIndex = (uint)rowIndex
            };

            //sheetData.AppendChild(row);
            foreach (IXlCell cell in rowData)
            {
                string cellReference = CellIndexHelper.FormatCellIndex(rowIndex, columnIndex);
                Cell   newCell       = new Cell()
                {
                    CellReference = cellReference, StyleIndex = cell.CellStyle
                };
                row.AppendChild(newCell);
                SetCellValue(cell.CellValue, cell.CellType, newCell, stringsTable);
                columnIndex++;
            }
            sheetData.AppendChild(row); //moved from above to ensure all cell writes are on the "standalone" row then just 1 DOM manip to insert row into sheet.
        }