Пример #1
0
            public static void SetValue(Cell cell, string text, SharedStringTableWithIndex sharedStringTable)
            {
                var index = sharedStringTable.SetSharedString(text == null ? "" : text);

                cell.CellValue = new CellValue(index.ToString());
                cell.DataType  = new EnumValue <CellValues>(CellValues.SharedString);
            }
Пример #2
0
            public SeedTable(string sheetName, Sheet sheet, Worksheet worksheet, SharedStringTableWithIndex sharedStringTable, int columnNamesRowIndex = 2, int dataStartRowIndex = 3, IEnumerable <string> ignoreColumnNames = null, string keyColumnName = "id", string versionColumnName = null) : base(columnNamesRowIndex, dataStartRowIndex, ignoreColumnNames, keyColumnName, versionColumnName)
            {
                SheetName         = sheetName;
                Sheet             = sheet;
                Worksheet         = worksheet;
                SharedStringTable = sharedStringTable;

                GetColumns();
            }
Пример #3
0
 public static string ValueString(Cell cell, SharedStringTableWithIndex sharedStringTable)
 {
     if (cell == null)
     {
         return(null);
     }
     // 数式
     if (cell.CellFormula != null)
     {
         //Console.WriteLine("FORMULA: "+cell.CellFormula.Text+" -> "+ cell.CellValue.Text);
         return(cell.CellValue.Text);
     }
     // SharedString以外
     if (cell.DataType == null || cell.DataType != CellValues.SharedString || sharedStringTable == null)
     {
         return(cell.InnerText);
     }
     // SharedString
     return(sharedStringTable.SharedString(int.Parse(cell.InnerText)));
 }
Пример #4
0
            public static object Value(Cell cell, SharedStringTableWithIndex sharedStringTable)
            {
                if (cell == null || cell.CellValue == null)
                {
                    return(null);
                }
                else if (cell.DataType == null)
                {
                    return(cell.CellValue.InnerText);
                }
                else
                {
                    string text = cell.CellFormula == null ? cell.CellValue.InnerText : cell.CellValue.Text;
                    switch (cell.DataType.Value)
                    {
                    case CellValues.InlineString:
                        return(text);

                    case CellValues.SharedString:
                        return(sharedStringTable.SharedString(int.Parse(text)));

                    case CellValues.String:
                        return(text);

                    case CellValues.Boolean:
                        return(text.Trim() != "0");

                    case CellValues.Date:
                        return(DateTime.Parse(text));

                    case CellValues.Error:
                        return(new Exception(text));

                    case CellValues.Number:
                        return(double.Parse(text));

                    default:
                        return(null);
                    }
                }
            }
Пример #5
0
 public ExcelData(SpreadsheetDocument document)
 {
     Document          = document;
     Sheets            = WorkbookPart.Workbook.Descendants <Sheet>();
     SharedStringTable = new SharedStringTableWithIndex(WorkbookPart.SharedStringTablePart.SharedStringTable, WorkbookPart);
 }
Пример #6
0
 public SeedTableCell(Cell cell, SharedStringTableWithIndex sharedStringTable)
 {
     Cell = cell;
     SharedStringTable = sharedStringTable;
 }
Пример #7
0
 public SeedTableRow(Row row, SharedStringTableWithIndex sharedStringTable)
 {
     Row = row;
     SharedStringTable = sharedStringTable;
 }