use of org.apache.poi.xssf.usermodel.XSSFSheet in project goci by EBISPOT.
the class SheetCellProcessingServiceTest method setUp.
@Before
public void setUp() throws Exception {
// Create spreadsheet for testing
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("test");
XSSFRow row = sheet.createRow(0);
row.createCell(0).setCellValue("this is a string");
row.createCell(1).setCellValue(12);
row.createCell(2).setCellValue(1.22);
row.createCell(3);
row.createCell(4).setCellValue("1.22");
cellWithString = row.getCell(0);
cellWithInteger = row.getCell(1);
cellWithFloat = row.getCell(2);
blankCell = row.getCell(3, row.RETURN_BLANK_AS_NULL);
cellWithNumericString = row.getCell(4);
}
use of org.apache.poi.xssf.usermodel.XSSFSheet in project cubrid-manager by CUBRID.
the class Export method createSheetWriter.
/**
* Create the instance of SpreadsheetWriter and based upon the given
* condition writing the header of a sheet
*
* @param workbook the instance of Workbook
* @param sheetName the name of a sheet
* @param fileMap a map includes the temporary file and its name
* @return the instance of XlsxWriterHelper.SpreadsheetWriter
*/
private XlsxWriterHelper.SpreadsheetWriter createSheetWriter(XSSFWorkbook workbook, String sheetName, Map<String, File> fileMap) {
// FIXME move this logic to core module
XSSFSheet sheet = workbook.createSheet(sheetName);
String sheetRef = sheet.getPackagePart().getPartName().getName().substring(1);
File tmp = null;
XlsxWriterHelper.SpreadsheetWriter sheetWriter = null;
try {
tmp = File.createTempFile(sheetName, ".xml");
fileMap.put(sheetRef, tmp);
String charset = null;
if (fileCharset == null || fileCharset.trim().length() == 0) {
charset = "UTF-8";
} else {
charset = fileCharset;
}
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(tmp), charset);
sheetWriter = new XlsxWriterHelper.SpreadsheetWriter(writer);
sheetWriter.setCharset(charset);
sheetWriter.beginSheet();
} catch (IOException ex) {
LOGGER.error(ex.getMessage());
}
return sheetWriter;
}
use of org.apache.poi.xssf.usermodel.XSSFSheet in project cubrid-manager by CUBRID.
the class ExportTableDataTask method createSheetWriter.
/**
* Create the instance of SpreadsheetWriter and based upon the given
* condition writing the header of a sheet
*
* @param workbook the instance of Workbook
* @param xlsxWriterhelper the instance of XlsxWriterHelper
* @param sheetNum the number of a sheet
* @param fileMap a map includes the temporary file and its name
* @param columnTitles the column title
* @param xssfRowNum the number of row
* @throws IOException the exception
* @return the instance of XlsxWriterHelper.SpreadsheetWriter
*/
private XlsxWriterHelper.SpreadsheetWriter createSheetWriter(XSSFWorkbook workbook, XlsxWriterHelper xlsxWriterhelper, int sheetNum, Map<String, File> fileMap, List<String> columnTitles, int xssfRowNum) throws IOException {
// FIXME move this logic to core module
XSSFSheet sheet = workbook.createSheet("sheet" + sheetNum);
String sheetRef = sheet.getPackagePart().getPartName().getName().substring(1);
File tmp = File.createTempFile("sheet" + sheetNum, ".xml");
fileMap.put(sheetRef, tmp);
String charset = null;
if (fileCharset == null || fileCharset.trim().length() == 0) {
charset = "UTF-8";
} else {
charset = fileCharset;
}
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(tmp), charset);
XlsxWriterHelper.SpreadsheetWriter sheetWriter = new XlsxWriterHelper.SpreadsheetWriter(writer);
sheetWriter.setCharset(charset);
sheetWriter.beginSheet();
if (isFirstRowAsColumnName && columnTitles != null) {
sheetWriter.insertRow(xssfRowNum);
int styleIndex = ((XSSFCellStyle) xlsxWriterhelper.getStyles(workbook).get("header")).getIndex();
for (int index = 0; index < columnTitles.size(); index++) {
sheetWriter.createCell(index, columnTitles.get(index), styleIndex);
}
sheetWriter.endRow();
}
return sheetWriter;
}
use of org.apache.poi.xssf.usermodel.XSSFSheet in project cubrid-manager by CUBRID.
the class ExportToXlsxHandler method createSheetWriter.
/**
* Create the instance of SpreadsheetWriter and based upon the given
* condition writing the header of a sheet
*
* @param workbook the instance of Workbook
* @param xlsxWriterhelper the instance of XlsxWriterHelper
* @param sheetNum the number of a sheet
* @param fileMap a map includes the temporary file and its name
* @param columnTitles the column title
* @param xssfRowNum the number of row
* @throws IOException the exception
* @return the instance of XlsxWriterHelper.SpreadsheetWriter
*/
private XlsxWriterHelper.SpreadsheetWriter createSheetWriter(XSSFWorkbook workbook, XlsxWriterHelper xlsxWriterhelper, int sheetNum, Map<String, File> fileMap, List<String> columnTitles, int xssfRowNum) throws IOException {
// FIXME move this logic to core module
XSSFSheet sheet = workbook.createSheet("sheet" + sheetNum);
String sheetRef = sheet.getPackagePart().getPartName().getName().substring(1);
File tmp = File.createTempFile("sheet" + sheetNum, ".xml");
fileMap.put(sheetRef, tmp);
String charset = null;
if (StringUtil.isEmpty(exportConfig.getFileCharset())) {
charset = "UTF-8";
} else {
charset = exportConfig.getFileCharset();
}
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(tmp), charset);
XlsxWriterHelper.SpreadsheetWriter sheetWriter = new XlsxWriterHelper.SpreadsheetWriter(writer);
sheetWriter.setCharset(charset);
sheetWriter.beginSheet();
if (exportConfig.isFirstRowAsColumnName() && columnTitles != null) {
sheetWriter.insertRow(xssfRowNum);
int styleIndex = ((XSSFCellStyle) xlsxWriterhelper.getStyles(workbook).get("header")).getIndex();
for (int index = 0; index < columnTitles.size(); index++) {
sheetWriter.createCell(index, columnTitles.get(index), styleIndex);
}
sheetWriter.endRow();
}
return sheetWriter;
}
use of org.apache.poi.xssf.usermodel.XSSFSheet in project lucene-solr by apache.
the class TestXLSXResponseWriter method getWSResultForQuery.
private XSSFSheet getWSResultForQuery(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException, Exception {
ByteArrayOutputStream xmlBout = new ByteArrayOutputStream();
writerXlsx.write(xmlBout, req, rsp);
XSSFWorkbook output = new XSSFWorkbook(new ByteArrayInputStream(xmlBout.toByteArray()));
XSSFSheet sheet = output.getSheetAt(0);
req.close();
output.close();
return sheet;
}
Aggregations