Пример #1
0
        /**
         * Gets the cell format
         *
         * @return the cell format
         */
        public CellFormat getCellFormat()
        {
            if (!initialized)
            {
                cellFormat  = formattingRecords.getXFRecord(xfIndex);
                initialized = true;
            }

            return(cellFormat);
        }
Пример #2
0
 /**
  * Constructor used when copying an existing spreadsheet
  *
  * @param col the column number
  * @param cir the column info record read in
  * @param fr  the format records
  */
 public ColumnInfoRecord(CSharpJExcel.Jxl.Read.Biff.ColumnInfoRecord cir, int col, FormattingRecords fr)
     : base(Type.COLINFO)
 {
     column       = col;
     width        = cir.getWidth();
     xfIndex      = cir.getXFIndex();
     style        = fr.getXFRecord(xfIndex);
     outlineLevel = cir.getOutlineLevel();
     collapsed    = cir.getCollapsed();
 }
Пример #3
0
        /**
         * Gets the column width for the specified column
         *
         * @param col the column number
         * @return the column format, or the default format if no override is
         *                 specified
         */
        public CellView getColumnView(int col)
        {
            ColumnInfoRecord cir = getColumnInfo(col);
            CellView         cv  = new CellView();

            if (cir != null)
            {
                cv.setDimension(cir.getWidth() / 256);                 //deprecated
                cv.setSize(cir.getWidth());
                cv.setHidden(cir.getHidden());
                cv.setFormat(formattingRecords.getXFRecord(cir.getXFIndex()));
            }
            else
            {
                cv.setDimension(settings.getDefaultColumnWidth());                 //deprecated
                cv.setSize(settings.getDefaultColumnWidth() * 256);
            }

            return(cv);
        }
Пример #4
0
        /// <summary> Gets the column width for the specified column
        ///
        /// </summary>
        /// <param name="col">the column number
        /// </param>
        /// <returns> the column format, or the default format if no override is
        /// specified
        /// </returns>
        public virtual CellView getColumnView(int col)
        {
            ColumnInfoRecord cir = getColumnInfo(col);
            CellView         cv  = new CellView();

            if (cir != null)
            {
                cv.Dimension = (cir.Width / 256);                 //deprecated
                cv.Size      = cir.Width;
                cv.Hidden    = cir.Hidden;
                cv.Format    = formattingRecords.getXFRecord(cir.XFIndex);
            }
            else
            {
                cv.Dimension = (settings.DefaultColumnWidth / 256);                 //deprecated
                cv.Size      = (settings.DefaultColumnWidth);
            }

            return(cv);
        }
 /**
  * Constructor used when copying an existing spreadsheet
  *
  * @param col the column number
  * @param cir the column info record read in
  * @param fr  the format records
  */
 public ColumnInfoRecord(CSharpJExcel.Jxl.Read.Biff.ColumnInfoRecord cir,int col,FormattingRecords fr)
     : base(Type.COLINFO)
 {
     column = col;
     width = cir.getWidth();
     xfIndex = cir.getXFIndex();
     style = fr.getXFRecord(xfIndex);
     outlineLevel = cir.getOutlineLevel();
     collapsed = cir.getCollapsed();
 }
Пример #6
0
        /**
         * Copies a sheet from a read-only version to the writable version.
         * Performs shallow copies
         */
        public void copySheet()
        {
            shallowCopyCells();

            // Copy the column info records
            CSharpJExcel.Jxl.Read.Biff.ColumnInfoRecord[] readCirs = fromSheet.getColumnInfos();

            for (int i = 0; i < readCirs.Length; i++)
            {
                CSharpJExcel.Jxl.Read.Biff.ColumnInfoRecord rcir = readCirs[i];
                for (int j = rcir.getStartColumn(); j <= rcir.getEndColumn(); j++)
                {
                    ColumnInfoRecord cir = new ColumnInfoRecord(rcir, j,
                                                                formatRecords);
                    cir.setHidden(rcir.getHidden());
                    columnFormats.Add(cir);
                }
            }

            // Copy the hyperlinks
            Hyperlink[] hls = fromSheet.getHyperlinks();
            for (int i = 0; i < hls.Length; i++)
            {
                WritableHyperlink hr = new WritableHyperlink
                                           (hls[i], toSheet);
                hyperlinks.Add(hr);
            }

            // Copy the merged cells
            Range[] merged = fromSheet.getMergedCells();

            for (int i = 0; i < merged.Length; i++)
            {
                mergedCells.add(new SheetRangeImpl((SheetRangeImpl)merged[i], toSheet));
            }

            // Copy the row properties
            try
            {
                CSharpJExcel.Jxl.Read.Biff.RowRecord[] rowprops = fromSheet.getRowProperties();

                for (int i = 0; i < rowprops.Length; i++)
                {
                    RowRecord rr     = toSheet.getRowRecord(rowprops[i].getRowNumber());
                    XFRecord  format = rowprops[i].hasDefaultFormat() ?
                                       formatRecords.getXFRecord(rowprops[i].getXFIndex()) : null;
                    rr.setRowDetails(rowprops[i].getRowHeight(),
                                     rowprops[i].matchesDefaultFontHeight(),
                                     rowprops[i].isCollapsed(),
                                     rowprops[i].getOutlineLevel(),
                                     rowprops[i].getGroupStart(),
                                     format);
                    numRows = System.Math.Max(numRows, rowprops[i].getRowNumber() + 1);
                }
            }
            catch (RowsExceededException e)
            {
                // Handle the rows exceeded exception - this cannot occur since
                // the sheet we are copying from will have a valid number of rows
                Assert.verify(false);
            }

            // Copy the headers and footers
            //    sheetWriter.setHeader(new HeaderRecord(si.getHeader()));
            //    sheetWriter.setFooter(new FooterRecord(si.getFooter()));

            // Copy the page breaks
            int[] rowbreaks = fromSheet.getRowPageBreaks();

            if (rowbreaks != null)
            {
                for (int i = 0; i < rowbreaks.Length; i++)
                {
                    rowBreaks.Add(rowbreaks[i]);
                }
            }

            int[] columnbreaks = fromSheet.getColumnPageBreaks();

            if (columnbreaks != null)
            {
                for (int i = 0; i < columnbreaks.Length; i++)
                {
                    columnBreaks.Add(columnbreaks[i]);
                }
            }

            // Copy the charts
            sheetWriter.setCharts(fromSheet.getCharts());

            // Copy the drawings
            DrawingGroupObject[] dr = fromSheet.getDrawings();
            for (int i = 0; i < dr.Length; i++)
            {
                if (dr[i] is CSharpJExcel.Jxl.Biff.Drawing.Drawing)
                {
                    WritableImage wi = new WritableImage
                                           (dr[i], toSheet.getWorkbook().getDrawingGroup());
                    drawings.Add(wi);
                    images.Add(wi);
                }
                else if (dr[i] is CSharpJExcel.Jxl.Biff.Drawing.Comment)
                {
                    CSharpJExcel.Jxl.Biff.Drawing.Comment c =
                        new CSharpJExcel.Jxl.Biff.Drawing.Comment(dr[i],
                                                                  toSheet.getWorkbook().getDrawingGroup(),
                                                                  workbookSettings);
                    drawings.Add(c);

                    // Set up the reference on the cell value
                    CellValue cv = (CellValue)toSheet.getWritableCell(c.getColumn(),
                                                                      c.getRow());
                    Assert.verify(cv.getCellFeatures() != null);
                    cv.getWritableCellFeatures().setCommentDrawing(c);
                }
                else if (dr[i] is CSharpJExcel.Jxl.Biff.Drawing.Button)
                {
                    CSharpJExcel.Jxl.Biff.Drawing.Button b =
                        new CSharpJExcel.Jxl.Biff.Drawing.Button
                            (dr[i],
                            toSheet.getWorkbook().getDrawingGroup(),
                            workbookSettings);
                    drawings.Add(b);
                }
                else if (dr[i] is CSharpJExcel.Jxl.Biff.Drawing.ComboBox)
                {
                    CSharpJExcel.Jxl.Biff.Drawing.ComboBox cb =
                        new CSharpJExcel.Jxl.Biff.Drawing.ComboBox
                            (dr[i],
                            toSheet.getWorkbook().getDrawingGroup(),
                            workbookSettings);
                    drawings.Add(cb);
                }
                else if (dr[i] is CSharpJExcel.Jxl.Biff.Drawing.CheckBox)
                {
                    CSharpJExcel.Jxl.Biff.Drawing.CheckBox cb =
                        new CSharpJExcel.Jxl.Biff.Drawing.CheckBox
                            (dr[i],
                            toSheet.getWorkbook().getDrawingGroup(),
                            workbookSettings);
                    drawings.Add(cb);
                }
            }

            // Copy the data validations
            DataValidation rdv = fromSheet.getDataValidation();

            if (rdv != null)
            {
                dataValidation = new DataValidation(rdv,
                                                    toSheet.getWorkbook(),
                                                    toSheet.getWorkbook(),
                                                    workbookSettings);
                uint objid = dataValidation.getComboBoxObjectId();
                if (objid != 0)
                {
                    comboBox = (ComboBox)drawings[(int)objid];
                }
            }

            // Copy the conditional formats
            ConditionalFormat[] cf = fromSheet.getConditionalFormats();
            if (cf.Length > 0)
            {
                for (int i = 0; i < cf.Length; i++)
                {
                    conditionalFormats.Add(cf[i]);
                }
            }

            // Get the autofilter
            autoFilter = fromSheet.getAutoFilter();

            // Copy the workspace options
            sheetWriter.setWorkspaceOptions(fromSheet.getWorkspaceOptions());

            // Set a flag to indicate if it contains a chart only
            if (fromSheet.getSheetBof().isChart())
            {
                chartOnly = true;
                sheetWriter.setChartOnly();
            }

            // Copy the environment specific print record
            if (fromSheet.getPLS() != null)
            {
                if (fromSheet.getWorkbookBof().isBiff7())
                {
                    //logger.warn("Cannot copy Biff7 print settings record - ignoring");
                }
                else
                {
                    plsRecord = new PLSRecord(fromSheet.getPLS());
                }
            }

            // Copy the button property set
            if (fromSheet.getButtonPropertySet() != null)
            {
                buttonPropertySet = new ButtonPropertySetRecord
                                        (fromSheet.getButtonPropertySet());
            }

            // Copy the outline levels
            maxRowOutlineLevel    = fromSheet.getMaxRowOutlineLevel();
            maxColumnOutlineLevel = fromSheet.getMaxColumnOutlineLevel();
        }