Reading a Template Xls Before Writing Data

UI Components for JSF
Post Reply
pelikan
Posts: 10
Joined: 21 Sep 2009, 22:58

23 Sep 2009, 22:16

Is there any way for me to read a template xls file, and add some informations on it, like color of cell, width of columns and than I generate the file to export?

I tried to read a template file at preProcessor method, but at postProcessor my cells are not like the template. Is there any way for me to do that?

Tks,
Thiago Teixeira

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

24 Sep 2009, 00:37

The only way to manipulate the xls export is to use the processor hooks, as an example following is the way to change the cell colors;

http://97.107.138.40:8080/prime-showcas ... cessor.jsf

pelikan
Posts: 10
Joined: 21 Sep 2009, 22:58

24 Sep 2009, 13:55

I made my example based on this case, but I want to do is to read the color informations from a template and put these informations in the xls file i`m writing.

For example, if I have 2 templates file, one with all cell with green background and the other template with blue background.

I want to read one of the template files and put the color information under my new file. Only for test purpose I did something like this, and it`s not working, do you now why?

Code: Select all

public void preProcessXLS(Object document) throws IOException {
        HSSFWorkbook wb = (HSSFWorkbook) document;        
        HSSFSheet sheet = wb.createSheet();
        
        InputStream in = new FileInputStream(new File("c:\\template.xls"));
        HSSFWorkbook workbook = new HSSFWorkbook(in);

        sheet = workbook.getSheetAt(0);

    }
The sheet is being created, but all cells are empty.

Tks,
Thiago Teixeira

juangon
Posts: 69
Joined: 22 Mar 2009, 19:05

24 Sep 2009, 18:54

Cells are empty for me too using rich:datatable. Don't know why...

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

24 Sep 2009, 19:04

Your preprocessor creates a new excel ignoring the one excelexporter creates so that will not work. What you can do is read your template, extract color information from that if you can and copy that template information to the exported document.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests