Exemplo n.º 1
0
        /**
         * Indicates whether or not this cell is hidden, by virtue of either
         * the entire row or column being collapsed
         *
         * @return TRUE if this cell is hidden, FALSE otherwise
         */
        public bool isHidden()
        {
            ColumnInfoRecord cir = sheet.getColumnInfo(column);

            if (cir != null && cir.getWidth() == 0)
            {
                return(true);
            }

            RowRecord rr = sheet.getRowInfo(row);

            if (rr != null && (rr.getRowHeight() == 0 || rr.isCollapsed()))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        /**
         * Copies a sheet from a read-only version to the writable version.
         * Performs shallow copies
         */
        public void copySheet()
        {
            shallowCopyCells();

            // Copy the column formats
            foreach (ColumnInfoRecord cv in fromColumnFormats)
            {
                toColumnFormats.Add(cv);
            }

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

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

            try
            {
                RowRecord row    = null;
                RowRecord newRow = null;
                for (int i = 0; i < fromRows.Length; i++)
                {
                    row = fromRows[i];

                    if (row != null &&
                        (!row.isDefaultHeight() ||
                         row.isCollapsed()))
                    {
                        newRow = toSheet.getRowRecord(i);
                        newRow.setRowDetails(row.getRowHeight(),
                                             row.matchesDefaultFontHeight(),
                                             row.isCollapsed(),
                                             row.getOutlineLevel(),
                                             row.getGroupStart(),
                                             row.getStyle());
                    }
                }
            }
            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 horizontal page breaks
            toRowBreaks = new ArrayList(fromRowBreaks);

            // Copy the vertical page breaks
            toColumnBreaks = new ArrayList(fromColumnBreaks);

            // Copy the data validations
            if (fromDataValidation != null)
            {
                toDataValidation = new DataValidation
                                       (fromDataValidation,
                                       toSheet.getWorkbook(),
                                       toSheet.getWorkbook(),
                                       toSheet.getWorkbook().getSettings());
            }

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

            // Copy the drawings
            foreach (object o in fromDrawings)
            {
                if (o is CSharpJExcel.Jxl.Biff.Drawing.Drawing)
                {
                    WritableImage wi = new WritableImage
                                           ((CSharpJExcel.Jxl.Biff.Drawing.Drawing)o,
                                           toSheet.getWorkbook().getDrawingGroup());
                    toDrawings.Add(wi);
                    toImages.Add(wi);
                }

                // Not necessary to copy the comments, as they will be handled by
                // the deep copy of the individual cells
            }

            // Copy the workspace options
            sheetWriter.setWorkspaceOptions(fromWorkspaceOptions);

            // Copy the environment specific print record
            if (fromPLSRecord != null)
            {
                toPLSRecord = new PLSRecord(fromPLSRecord);
            }

            // Copy the button property set
            if (fromButtonPropertySet != null)
            {
                toButtonPropertySet = new ButtonPropertySetRecord(fromButtonPropertySet);
            }

            // Copy the hyperlinks
            foreach (WritableHyperlink hyperlink in fromHyperlinks)
            {
                WritableHyperlink hr = new WritableHyperlink(hyperlink, toSheet);
                toHyperlinks.Add(hr);
            }
        }