Ejemplo n.º 1
0
        static IWorkbook CreateWorkbook(Workbook workbook, ExcelVersion version)
        {
            IWorkbook iWorkbook;

            switch (version)
            {
            case ExcelVersion.Xls:
                iWorkbook = new HSSFWorkbook();
                break;

            case ExcelVersion.Xlsx:
                iWorkbook = new XSSFWorkbook();
                break;

            default: throw new InvalidEnumArgumentException("version", (int)version, version.GetType());
            }

            AddNames(iWorkbook, version, workbook.Names.ToArray());
            foreach (Worksheet worksheet in workbook.Worksheets)
            {
                ISheet sheet = iWorkbook.CreateSheet(worksheet.Name);
                AddValidations(sheet, version, worksheet.Validations.ToArray());
                AddRows(sheet, worksheet.Rows.ToArray());
                if (worksheet.IsHidden)
                {
                    iWorkbook.SetSheetHidden(worksheet.Index, SheetState.Hidden);
                }
            }

            return(iWorkbook);
        }
Ejemplo n.º 2
0
        static int GetMax(RowColumn rowColumn, ExcelVersion version)
        {
            switch (rowColumn)
            {
            case RowColumn.Row:
                switch (version)
                {
                case ExcelVersion.Xls: return(RowMaxXls);

                case ExcelVersion.Xlsx: return(RowMaxXlsx);
                }
                break;

            case RowColumn.Column:
                switch (version)
                {
                case ExcelVersion.Xls: return(ColumnMaxXls);

                case ExcelVersion.Xlsx: return(ColumnMaxXlsx);
                }
                break;
            }
            throw new InvalidEnumArgumentException("version", (int)version, version.GetType());
        }