Bug 29747 - Bug in HSSFWorkbook:setRepeatingRowsAndColumns
Summary: Bug in HSSFWorkbook:setRepeatingRowsAndColumns
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.0-FINAL
Hardware: All All
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-23 03:07 UTC by jimmy Zhang
Modified: 2021-03-11 08:25 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jimmy Zhang 2004-06-23 03:07:12 UTC
When we create a workbook from existing Excel file and create a new sheet from 
the work book, the "setRepeatingRowsAndColumns" method does not work. I have 
write a Junit test case to test it, and it is repeatable.

The Junit test is bellow:



package org.apache.poi.hssf.usermodel;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;

import junit.framework.TestCase;

import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.BackupRecord;
import org.apache.poi.hssf.record.LabelSSTRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.aggregates.ValueRecordsAggregate;
import org.apache.poi.hssf.util.Region;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;


public class TestWorkbook
    extends TestCase
{

    /**
     * Constructor TestWorkbook
     *
     * @param name
     */

    public TestWorkbook(String name)
    {
        super(name);
    }

    
    /**
     * Generate a file to visually/programmatically verify repeating rows and 
cols made it
     */
    public void testRepeatingColsRows() throws IOException
    {
      FileInputStream fis = new FileInputStream(new File
("c://temp//myExistFile.xls"));		
      HSSFWorkbook workbook = new HSSFWorkbook(fis);        
		HSSFSheet sheet = workbook.createSheet("Test Print 
Titles");                
		String sheetName = workbook.getSheetName(0);
	     
	    HSSFRow row = sheet.createRow(0);
	    
	    HSSFCell cell = row.createCell((short)1);
	    cell.setCellValue("hi");
	     
	     
		workbook.setRepeatingRowsAndColumns(workbook.getSheetIndex
("Test Print Titles"), 0, 1, 0, 0); 
	     
		File file;// = File.createTempFile
("testPrintTitles",".xls");        
                
                file = new File("c://temp//mytest.xls");
	     
		FileOutputStream fileOut = new FileOutputStream(file);
		workbook.write(fileOut);
		fileOut.close();
	     
		assertTrue("file exists",file.exists());
	     
    	
    }
  
    
    public static void main(String [] ignored_args)
    {
        String filename = System.getProperty("HSSF.testdata.path");

        // assume this is relative to basedir
        if (filename == null)
        {
            System.setProperty(
                "HSSF.testdata.path",
                "src/testcases/org/apache/poi/hssf/data");
        }
        System.out
            .println("Testing org.apache.poi.hssf.usermodel.HSSFWorkbook");
        junit.textui.TestRunner.run(TestWorkbook.class);
    }
}
Comment 1 Glen Stampoultzis 2004-06-27 11:11:10 UTC
Fixed.  Was result of not setting correct index record in the name record.  Was
using extern sheet index rather than actual sheet index.