mirror of https://github.com/apache/poi.git
Allow common tests to do auto-sizing even on SXSSF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1729848 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b2d6b7c51a
commit
f597a1717c
|
@ -30,7 +30,9 @@ import org.apache.poi.POIDataSamples;
|
|||
import org.apache.poi.ss.ITestDataProvider;
|
||||
import org.apache.poi.ss.SpreadsheetVersion;
|
||||
import org.apache.poi.ss.usermodel.FormulaEvaluator;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
@ -85,6 +87,13 @@ public final class SXSSFITestDataProvider implements ITestDataProvider {
|
|||
return wb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trackColumnsForAutosizing(Sheet sheet, int...columns) {
|
||||
for (int cn : columns) {
|
||||
((SXSSFSheet)sheet).trackColumnForAutoSizing(cn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FormulaEvaluator createFormulaEvaluator(Workbook wb) {
|
||||
return new XSSFFormulaEvaluator(((SXSSFWorkbook) wb).getXSSFWorkbook());
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.poi.POIDataSamples;
|
|||
import org.apache.poi.ss.ITestDataProvider;
|
||||
import org.apache.poi.ss.SpreadsheetVersion;
|
||||
import org.apache.poi.ss.usermodel.FormulaEvaluator;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
@ -53,6 +54,9 @@ public final class XSSFITestDataProvider implements ITestDataProvider {
|
|||
return new XSSFWorkbook();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trackColumnsForAutosizing(Sheet sheet, int...columns) {}
|
||||
|
||||
@Override
|
||||
public FormulaEvaluator createFormulaEvaluator(Workbook wb) {
|
||||
return new XSSFFormulaEvaluator((XSSFWorkbook) wb);
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|||
import org.apache.poi.ss.ITestDataProvider;
|
||||
import org.apache.poi.ss.SpreadsheetVersion;
|
||||
import org.apache.poi.ss.usermodel.FormulaEvaluator;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
/**
|
||||
|
@ -59,6 +60,9 @@ public final class HSSFITestDataProvider implements ITestDataProvider {
|
|||
return new HSSFWorkbook();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trackColumnsForAutosizing(Sheet sheet, int...columns) {}
|
||||
|
||||
@Override
|
||||
public FormulaEvaluator createFormulaEvaluator(Workbook wb) {
|
||||
return new HSSFFormulaEvaluator((HSSFWorkbook) wb);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.apache.poi.ss;
|
||||
|
||||
import org.apache.poi.ss.usermodel.FormulaEvaluator;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
|
||||
/**
|
||||
|
@ -45,6 +46,12 @@ public interface ITestDataProvider {
|
|||
* @return an instance of Workbook
|
||||
*/
|
||||
Workbook createWorkbook();
|
||||
|
||||
/**
|
||||
* Only matters for SXSSF - enables tracking of the column
|
||||
* widths so that autosizing can work. No-op on others.
|
||||
*/
|
||||
void trackColumnsForAutosizing(Sheet sheet, int...columns);
|
||||
|
||||
/**
|
||||
* Creates the corresponding {@link FormulaEvaluator} for the
|
||||
|
|
Loading…
Reference in New Issue