*/
public void setActiveCellRow(int row) {
field_2_row_active_cell = row;
+ resetField6();
}
/**
*/
public void setActiveCellCol(short col) {
field_3_col_active_cell = col;
+ resetField6();
+ }
+
+ private void resetField6() {
+ // this is necessary in Excel to actually make Workbook.setActiveCell() take effect
+ field_6_refs = new CellRangeAddress8Bit[] {
+ new CellRangeAddress8Bit(field_2_row_active_cell, field_2_row_active_cell, field_3_col_active_cell, field_3_col_active_cell),
+ };
}
/**
@Override
public String toString() {
- StringBuffer sb = new StringBuffer();
-
- sb.append("[SELECTION]\n");
- sb.append(" .pane = ").append(HexDump.byteToHex(getPane())).append("\n");
- sb.append(" .activecellrow = ").append(HexDump.shortToHex(getActiveCellRow())).append("\n");
- sb.append(" .activecellcol = ").append(HexDump.shortToHex(getActiveCellCol())).append("\n");
- sb.append(" .activecellref = ").append(HexDump.shortToHex(getActiveCellRef())).append("\n");
- sb.append(" .numrefs = ").append(HexDump.shortToHex(field_6_refs.length)).append("\n");
- sb.append("[/SELECTION]\n");
- return sb.toString();
+ return "[SELECTION]\n" +
+ " .pane = " + HexDump.byteToHex(getPane()) + "\n" +
+ " .activecellrow = " + HexDump.shortToHex(getActiveCellRow()) + "\n" +
+ " .activecellcol = " + HexDump.shortToHex(getActiveCellCol()) + "\n" +
+ " .activecellref = " + HexDump.shortToHex(getActiveCellRef()) + "\n" +
+ " .numrefs = " + HexDump.shortToHex(field_6_refs.length) + "\n" +
+ "[/SELECTION]\n";
}
+
@Override
protected int getDataSize() {
return 9 // 1 byte + 4 shorts
import org.apache.poi.POIXMLException;
import org.apache.poi.POIXMLProperties;
import org.apache.poi.common.usermodel.HyperlinkType;
+import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.util.ZipSecureFile;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.ConditionalFormattingEvaluator;
import org.apache.poi.ss.formula.EvaluationConditionalFormatRule;
import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.AreaReference;
+import org.apache.poi.ss.util.CellAddress;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.ss.util.CellUtil;
sheet.autoSizeColumn(i);
}
}
+
+ @Test
+ public void test61905xlsx() throws IOException {
+ Workbook wb = new XSSFWorkbook();
+ checkActiveSheet(wb, XSSFITestDataProvider.instance);
+ wb.close();
+ }
+
+ @Test
+ public void test61905xls() throws IOException {
+ Workbook wb = new HSSFWorkbook();
+ checkActiveSheet(wb, HSSFITestDataProvider.instance);
+ wb.close();
+ }
+
+ private void checkActiveSheet(Workbook wb, ITestDataProvider instance) throws IOException {
+ Sheet sheet = wb.createSheet("new sheet");
+ sheet.setActiveCell(new CellAddress("E11"));
+ assertEquals("E11", sheet.getActiveCell().formatAsString());
+
+ Workbook wbBack = instance.writeOutAndReadBack(wb);
+ sheet = wbBack.getSheetAt(0);
+ assertEquals("E11", sheet.getActiveCell().formatAsString());
+ wbBack.close();
+
+ //wb.write(new FileOutputStream("c:/temp/61905." + instance.getStandardFileNameExtension()));
+ }
}