001/*
002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Martin Pernollet
016 */
017
018package org.nuxeo.ecm.platform.groups.audit.service.acl.excel;
019
020import java.io.File;
021import java.io.IOException;
022import java.util.Collection;
023
024import org.apache.poi.hssf.util.HSSFColor;
025import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
026import org.apache.poi.ss.usermodel.Cell;
027import org.apache.poi.ss.usermodel.CellStyle;
028import org.apache.poi.ss.usermodel.Comment;
029import org.apache.poi.ss.usermodel.Font;
030import org.apache.poi.ss.usermodel.Sheet;
031import org.apache.poi.ss.usermodel.Workbook;
032
033public interface IExcelBuilder {
034    /**
035     * Set a cell content at the given indices, and apply the style if it is not null. If row(i) does not exist yet, it
036     * is created, otherwise it is recycled. If cell(i,j) does not exist yet, it is created, otherwise it is recycled.
037     * Reminder: excel support a maximum of 65,536 rows and 256 columns per sheet
038     *
039     * @param row row index
040     * @param column column index
041     * @param content a string to display in the cell
042     * @param style a style to apply to the cell
043     * @return the created or retrieved cell in case additional stuff should be done on it.
044     */
045    public Cell setCell(int row, int column, String content, CellStyle style);
046
047    /**
048     * Set a cell text content with no styling information.
049     *
050     * @see {@link setCell(int i, int j, String content, CellStyle style)}
051     */
052    public Cell setCell(int row, int column, String content);
053
054    public Sheet getCurrentSheet();
055
056    public Collection<Sheet> getAllSheets();
057
058    public int getCurrentSheetId();
059
060    public void setCurrentSheetId(int s);
061
062    public int newSheet(int index, String name);
063
064    public void setRowHeight(int row, int height);
065
066    /** Set the width (in units of 1/256th of a character width) */
067    public void setColumnWidth(int column, int width);
068
069    public void setColumnWidthAuto(int column);
070
071    public void setFreezePane(int colSplit, int rowSplit);
072
073    public void setFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow);
074
075    public void setSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane);
076
077    public void mergeRange(int firstRow, int firstColumn, int lastRow, int lastColumn);
078
079    public Comment addComment(Cell cell, String text, int row, int col, int colWidth, int rowHeight);
080
081    public CellStyle newColoredCellStyle(ByteColor color);
082
083    public void save(String file) throws IOException;
084
085    public void save(File file) throws IOException;
086
087    public Workbook load(String file) throws InvalidFormatException, IOException;
088
089    public Workbook load(File file) throws InvalidFormatException, IOException;
090
091    public Font newFont(int size);
092
093    public Font newFont();
094
095    public Font getBoldFont();
096
097    public CellStyle newCellStyle();
098
099    public Workbook getWorkbook();
100
101    public HSSFColor getColor(ByteColor color);
102
103    public int loadPicture(String image) throws IOException;
104
105    public void setPicture(int pictureIdx, int col1, int row1, boolean resize);
106
107}