001/*
002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Martin Pernollet
018 */
019
020package org.nuxeo.ecm.platform.groups.audit.service.acl.excel;
021
022import java.io.File;
023import java.io.IOException;
024import java.util.Collection;
025
026import org.apache.poi.hssf.util.HSSFColor;
027import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
028import org.apache.poi.ss.usermodel.Cell;
029import org.apache.poi.ss.usermodel.CellStyle;
030import org.apache.poi.ss.usermodel.Comment;
031import org.apache.poi.ss.usermodel.Font;
032import org.apache.poi.ss.usermodel.Sheet;
033import org.apache.poi.ss.usermodel.Workbook;
034
035public interface IExcelBuilder {
036    /**
037     * 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
038     * is created, otherwise it is recycled. If cell(i,j) does not exist yet, it is created, otherwise it is recycled.
039     * Reminder: excel support a maximum of 65,536 rows and 256 columns per sheet
040     *
041     * @param row row index
042     * @param column column index
043     * @param content a string to display in the cell
044     * @param style a style to apply to the cell
045     * @return the created or retrieved cell in case additional stuff should be done on it.
046     */
047    public Cell setCell(int row, int column, String content, CellStyle style);
048
049    /**
050     * Set a cell text content with no styling information.
051     *
052     * @see {@link setCell(int i, int j, String content, CellStyle style)}
053     */
054    public Cell setCell(int row, int column, String content);
055
056    public Sheet getCurrentSheet();
057
058    public Collection<Sheet> getAllSheets();
059
060    public int getCurrentSheetId();
061
062    public void setCurrentSheetId(int s);
063
064    public int newSheet(int index, String name);
065
066    public void setRowHeight(int row, int height);
067
068    /** Set the width (in units of 1/256th of a character width) */
069    public void setColumnWidth(int column, int width);
070
071    public void setColumnWidthAuto(int column);
072
073    public void setFreezePane(int colSplit, int rowSplit);
074
075    public void setFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow);
076
077    public void setSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane);
078
079    public void mergeRange(int firstRow, int firstColumn, int lastRow, int lastColumn);
080
081    public Comment addComment(Cell cell, String text, int row, int col, int colWidth, int rowHeight);
082
083    public CellStyle newColoredCellStyle(ByteColor color);
084
085    public void save(String file) throws IOException;
086
087    public void save(File file) throws IOException;
088
089    public Workbook load(String file) throws InvalidFormatException, IOException;
090
091    public Workbook load(File file) throws InvalidFormatException, IOException;
092
093    public Font newFont(int size);
094
095    public Font newFont();
096
097    public Font getBoldFont();
098
099    public CellStyle newCellStyle();
100
101    public Workbook getWorkbook();
102
103    public HSSFColor getColor(ByteColor color);
104
105    public int loadPicture(String image) throws IOException;
106
107    public void setPicture(int pictureIdx, int col1, int row1, boolean resize);
108
109}