⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gnumericwriter.java

📁 非常实用的java描述的excel组件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     */
    private void writeMaxCol(Worksheet worksheet, PrintStream out, String indent) {

        out.println(indent + "<gmr:MaxCol>" + worksheet.getMaxColumn() + "</gmr:MaxCol>");

    }

    /**
     * Writes the maximum row element.
     * 
     * @param worksheet  the worksheet.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeMaxRow(Worksheet worksheet, PrintStream out, String indent) {

        out.println(indent + "<gmr:MaxRow>" + worksheet.getMaxRow() + "</gmr:MaxRow>");

    }

    /**
     * Writes the zoom element.
     * 
     * @param worksheet  the worksheet.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeZoom(Worksheet worksheet, PrintStream out, String indent) {

        out.println(indent + "<gmr:Zoom>" + worksheet.getZoom() + "</gmr:Zoom>");

    }

    /**
     * Writes out an objects element.  Only comment objects are supported by JWorkbook for now.
     * 
     * @param worksheet  the worksheet.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeObjects(Worksheet worksheet, PrintStream out, String indent) {

        out.println(indent + "<gmr:Objects>");
        Iterator iterator = worksheet.getComments().iterator();
        while (iterator.hasNext()) {
            Comment comment = (Comment) iterator.next();
            writeComment(comment, out, indent + INDENT);
        }
        out.println(indent + "</gmr:Objects>");

    }

    /**
     * Writes a print information element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    public void writePrintInformation(PrintInformation info, PrintStream out, String indent) {

        out.println(indent + "<gmr:PrintInformation>");

        String nextIndent = indent + INDENT;

        writeMargins(info.getMargins(), out, nextIndent);
        writeVerticallyCentered(info, out, nextIndent);
        writeHorizontallyCentered(info, out, nextIndent);
        writeGridVisible(info, out, nextIndent);
        writeMonochrome(info, out, nextIndent);
        writeDraft(info, out, nextIndent);
        writeTitles(info, out, nextIndent);
        writeRepeatTop(info, out, nextIndent);
        writeRepeatLeft(info, out, nextIndent);
        writeOrder(info, out, nextIndent);
        writeOrientation(info, out, nextIndent);
        writeHeader(info, out, nextIndent);
        writeFooter(info, out, nextIndent);
        writePaper(info, out, nextIndent);

        out.println(indent + "</gmr:PrintInformation>");

    }

    /**
     * Writes a vcenter element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeVerticallyCentered(PrintInformation info, PrintStream out, String indent) {

        String center = (info.isVerticallyCentered() ? "1" : "0");
        out.println(indent + "<gmr:vcenter value=\"" + center + "\"/>");

    }

    /**
     * Writes a hcenter element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeHorizontallyCentered(PrintInformation info, PrintStream out, String indent) {

        String center = (info.isHorizontallyCentered() ? "1" : "0");
        out.println(indent + "<gmr:hcenter value=\"" + center + "\"/>");

    }

    /**
     * Writes a grid visible element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeGridVisible(PrintInformation info, PrintStream out, String indent) {

        String grid = (info.isGridVisible() ? "1" : "0");
        out.println(indent + "<gmr:grid value=\"" + grid + "\"/>");

    }

    /**
     * Writes a monochrome element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeMonochrome(PrintInformation info, PrintStream out, String indent) {

        String flag = (info.isMonochrome() ? "1" : "0");
        out.println(indent + "<gmr:monochrome value=\"" + flag + "\"/>");

    }

    /**
     * Writes a draft element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeDraft(PrintInformation info, PrintStream out, String indent) {

        String flag = (info.isDraft() ? "1" : "0");
        out.println(indent + "<gmr:draft value=\"" + flag + "\"/>");

    }

    /**
     * Writes a titles element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeTitles(PrintInformation info, PrintStream out, String indent) {

        String flag = (info.isTitlesVisible() ? "1" : "0");
        out.println(indent + "<gmr:titles value=\"" + flag + "\"/>");

    }

    /**
     * Writes a repeat_top element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeRepeatTop(PrintInformation info, PrintStream out, String indent) {

        out.println(indent + "<gmr:repeat_top value=\"" + info.getRepeatTop() + "\"/>");

    }

    /**
     * Writes a repeat_left element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeRepeatLeft(PrintInformation info, PrintStream out, String indent) {

        out.println(indent + "<gmr:repeat_left value=\"" + info.getRepeatLeft() + "\"/>");

    }

    /**
     * Writes an order element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeOrder(PrintInformation info, PrintStream out, String indent) {

        out.println(indent + "<gmr:order>" + info.getOrder() + "</gmr:order>");

    }

    /**
     * Writes an orientation element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeOrientation(PrintInformation info, PrintStream out, String indent) {

        if (info.getOrientation() == 0) {
            out.println(indent + "<gmr:orientation>landscape</gmr:orientation>");
        }
        else {
            out.println(indent + "<gmr:orientation>portrait</gmr:orientation>");
        }

    }

    /**
     * Writes a header element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeHeader(PrintInformation info, PrintStream out, String indent) {

        out.println(indent + "<gmr:Header Left=\"" + info.getHeaderLeft()
                           + "\" Middle=\"" + info.getHeaderMiddle()
                           + "\" Right=\"" + info.getHeaderRight() + "\"/>");

    }

    /**
     * Writes a footer element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writeFooter(PrintInformation info, PrintStream out, String indent) {

        out.println(indent + "<gmr:Footer Left=\"" + info.getFooterLeft()
                           + "\" Middle=\"" + info.getFooterMiddle()
                           + "\" Right=\"" + info.getFooterRight() + "\"/>");

    }

    /**
     * Writes a paper element to the stream.
     * 
     * @param info  print information.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    private void writePaper(PrintInformation info, PrintStream out, String indent) {

        out.println(indent + "<gmr:paper>" + info.getPaperSize() + "</gmr:paper>");

    }

    /**
     * Writes a styles element to the stream.
     * 
     * @param styles  the styles.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    public void writeStyles(Styles styles, PrintStream out, String indent) {

        out.println(indent + "<gmr:Styles>");

        Iterator iterator = styles.getStylesIterator();
        while (iterator.hasNext()) {
            StyleRegion region = (StyleRegion) iterator.next();
            writeStyleRegion(region, out, indent + INDENT);
        }

        out.println(indent + "</gmr:Styles>");

    }

    /**
     * Writes the columns element to the specified stream.
     * 
     * @param columnAttributes  the column attributes.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    public void writeColumns(ColumnAttributesManager columnAttributes,
                             PrintStream out, String indent) {

        out.println(indent + "<gmr:Cols DefaultSizePts=\""
                           + columnAttributes.getDefaultColumnWidth() + "\">");

        Iterator iterator = columnAttributes.getAttributesIterator();
        while (iterator.hasNext()) {
            ColumnAttributes attributes = (ColumnAttributes) iterator.next();
            writeColInfo(attributes, out, indent + INDENT);
        }

        out.println(indent + "</gmr:Cols>");

    }

    /**
     * Writes the rows element to the specified stream.
     * 
     * @param rowAttributes  the row attributes.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    public void writeRows(RowAttributesManager rowAttributes, PrintStream out, String indent) {

        out.println(indent + "<gmr:Rows DefaultSizePts=\""
                           + rowAttributes.getDefaultRowHeight()
                           + "\">");

        Iterator iterator = rowAttributes.getAttributesIterator();
        while (iterator.hasNext()) {
            RowAttributes attributes = (RowAttributes) iterator.next();
            writeRowInfo(attributes, out, indent + INDENT);
        }

        out.println(indent + "</gmr:Rows>");

    }

    /**
     * Writes a selections element to the stream.
     * 
     * @param selections  the selections.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    public void writeSelections(Selections selections, PrintStream out, String indent) {

        out.println(indent + "<gmr:Selections "
                           + "CursorCol=\"" + selections.getCursorColumn() + "\" "
                           + "CursorRow=\"" + selections.getCursorRow()
                           + "\">");

        Iterator iterator = selections.getIterator();
        while (iterator.hasNext()) {
            Selection selection = (Selection) iterator.next();
            writeSelection(selection, out, indent + INDENT);
        }

        out.println(indent + "</gmr:Selections>");

    }

    /**
     * Writes the cells to the specified stream in the format required by the Gnumeric XML file.
     * 
     * @param cells  the cells.
     * @param out  the output stream.
     * @param indent  the indentation.
     */
    public void writeCells(Cells cells, PrintStream out, String indent) {

        out.println(indent + "<gmr:Cells>");
        Iterator iterator = cells.getRowsIterator();
        while (iterator.hasNext()) {
            Row row = (Row) iterator.next();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -