poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 28328] New: - sheet selection does not work
Date Sat, 10 Apr 2004 09:16:12 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=28328>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28328

sheet selection does not work

           Summary: sheet selection does not work
           Product: POI
           Version: 2.0FINAL
          Platform: PC
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: csage@capita.de


Using various methods I cannot get a second sheet to retain its status as 
selected after saving it. Because I am not 100% sure that it's not me being 
stupid I am including a test case here (after all I am new to POI and not too 
experienced in Java). I use Java 1.4.2_04 and POI-2.5-final on Windows XP Pro, 
and I open the resulting workbook in MS Excel 2002 SP-2. The test case follows 
after "---< cut". Neither of the three selection methods included (one active 
and two others commented out) work for me.

---< cut
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFFooter;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;


public class PoiTest19 {
	
	public static void main(String[] args) {
		HSSFWorkbook workbook;
		HSSFSheet worksheet;
		HSSFFooter footer;
		HSSFRow row;
		HSSFCell cell;
		
		workbook = new HSSFWorkbook();
		worksheet = workbook.createSheet("empty sheet");
		worksheet = workbook.createSheet("sheet with rows");
		
		footer = worksheet.getFooter();
		footer.setRight("Page " + HSSFFooter.page() + " of " + 
HSSFFooter.numPages());
		
		for (int i = 0; i < 134; i++) {
			row = worksheet.createRow(i);
			cell = row.createCell((short) 0);
			cell.setCellValue(i * 1000 + i * (i + 1));
		}
		
		worksheet.setSelected(true);
		// workbook.getSheetAt(1).setSelected(true);
		// workbook.getSheetAt(workbook.getSheetIndex("sheet with 
rows")).setSelected(true);
		
		try {
			FileOutputStream ausgabeDatei = new FileOutputStream
("poi_test.xls");
			workbook.write(ausgabeDatei);
			ausgabeDatei.close();
		}
		catch(FileNotFoundException fnfE) {
			System.out.println("Datei nicht vorhanden!");
			fnfE.printStackTrace();
		}
		catch(IOException ioE) {
			System.out.println("Ein Ein-/Ausgabe-Fehler ist 
aufgetreten!");
			ioE.printStackTrace();
		}
	}
	
}

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org


Mime
View raw message