Пример #1
0
        /**
         * Called when the cell is added to the worksheet in order to indicate
         * that this object is already added to the worksheet
         * This method also verifies that the associated formats and formats
         * have been initialized correctly
         *
         * @param fr the formatting records
         * @param ss the shared strings used within the workbook
         * @param s the sheet this is being added to
         */
        public virtual void setCellDetails(FormattingRecords fr, SharedStrings ss,
                                           WritableSheetImpl s)
        {
            referenced        = true;
            sheet             = s;
            formattingRecords = fr;

            addCellFormat();
            addCellFeatures();
        }
Пример #2
0
        /**
         * Overrides the method in the base class in order to add the string
         * content to the shared string table, and to store its shared string
         * index
         *
         * @param fr the formatting records
         * @param ss the shared strings used within the workbook
         * @param s
         */
        public override void setCellDetails(FormattingRecords fr, SharedStrings ss,
                                            WritableSheetImpl s)
        {
            base.setCellDetails(fr, ss, s);

            sharedStrings = ss;

            index = sharedStrings.getIndex(contents);

            // Use the sharedStrings reference instead of this object's own
            // handle - this means that the bespoke copy becomes eligible for
            // garbage collection
            contents = sharedStrings.get(index);
        }
 /**
  * Overrides the method in the base class to add this to the Workbook's
  * list of maintained formulas
  *
  * @param fr the formatting records
  * @param ss the shared strings used within the workbook
  * @param s the sheet this is being added to
  */
 public override void setCellDetails(FormattingRecords fr, SharedStrings ss,
     WritableSheetImpl s)
 {
     base.setCellDetails(fr, ss, s);
     s.getWorkbook().addRCIRCell(this);
 }
        /**
         * A pseudo copy constructor.  Takes the handles to the font and formatting
         * records
         *
         * @exception IOException
         * @param w the workbook to copy
         * @param os the output stream to write the data to
         * @param cs TRUE if the workbook should close the output stream, FALSE
         * @param ws the configuration for this workbook
         */
        public WritableWorkbookImpl(Stream os,
            Workbook w,
            bool cs,
            WorkbookSettings ws)
            : base()
        {
            CSharpJExcel.Jxl.Read.Biff.WorkbookParser wp = (CSharpJExcel.Jxl.Read.Biff.WorkbookParser)w;

            // Reset the statically declared styles.  These are no longer needed
            // because the Styles class will intercept all calls within
            // CellValue.setCellDetails and if it detects a standard format, then it
            // will return a clone.  In short, the static cell values will
            // never get initialized anyway.  Still, just to be extra sure...
            //lock (SYNCHRONIZER)
            //    {
            //    WritableWorkbook.ARIAL_10_PT.uninitialize();
            //    WritableWorkbook.HYPERLINK_FONT.uninitialize();
            //    WritableWorkbook.NORMAL_STYLE.uninitialize();
            //    WritableWorkbook.HYPERLINK_STYLE.uninitialize();
            //    WritableWorkbook.HIDDEN_STYLE.uninitialize();
            //    DateRecord.defaultDateFormat.uninitialize();
            //    }

            closeStream = cs;
            sheets = new ArrayList();
            sharedStrings = new SharedStrings();
            nameRecords = new Dictionary<string, NameRecord>();
            fonts = wp.getFonts();
            formatRecords = wp.getFormattingRecords();
            wbProtected = false;
            settings = ws;
            rcirCells = new ArrayList();
            styles = new Styles();
            outputFile = new File(os, ws, wp.getCompoundFile());

            containsMacros = false;
            if (!ws.getPropertySetsDisabled())
                containsMacros = wp.containsMacros();

            // Copy the country settings
            if (wp.getCountryRecord() != null)
                countryRecord = new CountryRecord(wp.getCountryRecord());

            // Copy any add in functions
            addInFunctionNames = wp.getAddInFunctionNames();

            // Copy XCT records
            xctRecords = wp.getXCTRecords();

            // Copy any external sheets
            if (wp.getExternalSheetRecord() != null)
                {
                externSheet = new ExternalSheetRecord(wp.getExternalSheetRecord());

                // Get the associated supbooks
                CSharpJExcel.Jxl.Read.Biff.SupbookRecord[] readsr = wp.getSupbookRecords();
                supbooks = new ArrayList(readsr.Length);

                for (int i = 0; i < readsr.Length; i++)
                    {
                    CSharpJExcel.Jxl.Read.Biff.SupbookRecord readSupbook = readsr[i];
                    if (readSupbook.getType() == SupbookRecord.INTERNAL || readSupbook.getType() == SupbookRecord.EXTERNAL)
                        supbooks.Add(new SupbookRecord(readSupbook, settings));
                    else
                        {
                        if (readSupbook.getType() != SupbookRecord.ADDIN)
                            {
                            //logger.warn("unsupported supbook type - ignoring");
                            }
                        }
                    }
                }

            // Copy any drawings.  These must be present before we try and copy
            // the images from the read workbook
            if (wp.getDrawingGroup() != null)
                drawingGroup = new DrawingGroup(wp.getDrawingGroup());

            // Copy the property set references
            if (containsMacros && wp.getButtonPropertySet() != null)
                buttonPropertySet = new ButtonPropertySetRecord(wp.getButtonPropertySet());

            // Copy any names
            if (!settings.getNamesDisabled())
                {
                CSharpJExcel.Jxl.Read.Biff.NameRecord[] na = wp.getNameRecords();
                names = new ArrayList(na.Length);

                for (int i = 0; i < na.Length; i++)
                    {
                    if (na[i].isBiff8())
                        {
                        NameRecord n = new NameRecord(na[i], i);
                        names.Add(n);
                        string key = n.getName() == null ? NULLKEY : n.getName();
                        nameRecords.Add(key, n);
                        }
                    else
                        {
                        //logger.warn("Cannot copy Biff7 name records - ignoring");
                        }
                    }
                }

            copyWorkbook(w);

            // The copy process may have caused some critical fields in the
            // read drawing group to change.  Make sure these updates are reflected
            // in the writable drawing group
            if (drawingGroup != null)
                drawingGroup.updateData(wp.getDrawingGroup());
        }
        /**
         * Constructor.  Writes the workbook direct to the existing output stream
         *
         * @exception IOException
         * @param os the output stream
         * @param cs TRUE if the workbook should close the output stream, FALSE
         * @param ws the configuration for this workbook
         * otherwise
         */
        public WritableWorkbookImpl(Stream os, bool cs, WorkbookSettings ws)
            : base()
        {
            outputFile = new File(os, ws, null);
            sheets = new ArrayList();
            sharedStrings = new SharedStrings();
            nameRecords = new Dictionary<string, NameRecord>();
            closeStream = cs;
            wbProtected = false;
            containsMacros = false;
            settings = ws;
            rcirCells = new ArrayList();
            styles = new Styles();

            // Reset the statically declared styles.  These are no longer needed
            // because the Styles class will intercept all calls within
            // CellValue.setCellDetails and if it detects a standard format, then it
            // will return a clone.  In short, the static cell values will
            // never get initialized anyway.  Still, just to be extra sure...
            //lock (SYNCHRONIZER)
            //    {
            //    WritableWorkbook.ARIAL_10_PT.initialize();
            //    WritableWorkbook.HYPERLINK_FONT.initialize();
            //    WritableWorkbook.NORMAL_STYLE.initialize();
            //    WritableWorkbook.HYPERLINK_STYLE.initialize();
            //    WritableWorkbook.HIDDEN_STYLE.initialize();
            //    DateRecord.defaultDateFormat.initialize();
            //    }

            WritableFonts wf = new WritableFonts(this);
            fonts = wf;

            WritableFormattingRecords wfr = new WritableFormattingRecords(fonts,
                                                                          styles);
            formatRecords = wfr;
        }
Пример #6
0
        /**
         * Overrides the method in the base class in order to add the string
         * content to the shared string table, and to store its shared string
         * index
         *
         * @param fr the formatting records
         * @param ss the shared strings used within the workbook
         * @param s
         */
        public override void setCellDetails(FormattingRecords fr, SharedStrings ss,
            WritableSheetImpl s)
        {
            base.setCellDetails(fr, ss, s);

            sharedStrings = ss;

            index = sharedStrings.getIndex(contents);

            // Use the sharedStrings reference instead of this object's own
            // handle - this means that the bespoke copy becomes eligible for
            // garbage collection
            contents = sharedStrings.get(index);
        }
Пример #7
0
 /**
  * Called when the cell is added to the worksheet.  Overrides the
  * method in the base class in order to get a handle to the
  * WorkbookSettings so that this formula may be initialized
  *
  * @param fr the formatting records
  * @param ss the shared strings used within the workbook
  * @param s the sheet this is being added to
  */
 public override void setCellDetails(FormattingRecords fr, SharedStrings ss, WritableSheetImpl s)
 {
     base.setCellDetails(fr, ss, s);
     initialize(s.getWorkbookSettings(), s.getWorkbook(), s.getWorkbook());
     s.getWorkbook().addRCIRCell(this);
 }
Пример #8
0
        /**
         * Called when the cell is added to the worksheet in order to indicate
         * that this object is already added to the worksheet
         * This method also verifies that the associated formats and formats
         * have been initialized correctly
         *
         * @param fr the formatting records
         * @param ss the shared strings used within the workbook
         * @param s the sheet this is being added to
         */
        public virtual void setCellDetails(FormattingRecords fr, SharedStrings ss,
            WritableSheetImpl s)
        {
            referenced = true;
            sheet = s;
            formattingRecords = fr;

            addCellFormat();
            addCellFeatures();
        }