예제 #1
0
        /**
         * Writes out all the cells in this row.  If more than three integer
         * values occur consecutively, then a MulRK record is used to group the
         * numbers
         *
         * @exception IOException
         * @param outputFile the output file
         */
        public void writeCells(File outputFile)
        {
            // This is the list for integer values
            ArrayList integerValues = new ArrayList();
            bool integerValue = false;

            // Write out all the records
            for (int i = 0; i < numColumns; i++)
                {
                integerValue = false;
                if (cells[i] != null)
                    {
                    // See if this cell is a 30-bit integer value (without additional
                    // cell features)
                    if (cells[i].getType() == CellType.NUMBER)
                        {
                        Number nc = (Number)cells[i];
                        if (nc.getValue() == (int)nc.getValue() &&
                            nc.getValue() < maxRKValue &&
                            nc.getValue() > minRKValue &&
                            nc.getCellFeatures() == null)
                            {
                            integerValue = true;
                            }
                        }

                    if (integerValue)
                        {
                        // This cell is an integer, add it to the list
                        integerValues.Add(cells[i]);
                        }
                    else
                        {
                        // This cell is not an integer.  Write out whatever integers we
                        // have, and then write out this cell
                        writeIntegerValues(integerValues, outputFile);
                        outputFile.write(cells[i]);

                        // If the cell is a string formula, write out the string record
                        // immediately afterwards
                        if (cells[i].getType() == CellType.STRING_FORMULA)
                            {
                            StringRecord sr = new StringRecord(cells[i].getContents());
                            outputFile.write(sr);
                            }
                        }
                    }
                else
                    {
                    // Cell does not exist.  Write out the list of integers that
                    // we have
                    writeIntegerValues(integerValues, outputFile);
                    }
                }

            // All done.  Write out any remaining integer values
            writeIntegerValues(integerValues, outputFile);
        }