本文整理匯總了Java中org.apache.poi.xssf.usermodel.XSSFWorkbook.getCreationHelper方法的典型用法代碼示例。如果您正苦於以下問題:Java XSSFWorkbook.getCreationHelper方法的具體用法?Java XSSFWorkbook.getCreationHelper怎麽用?Java XSSFWorkbook.getCreationHelper使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.xssf.usermodel.XSSFWorkbook
的用法示例。
在下文中一共展示了XSSFWorkbook.getCreationHelper方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import org.apache.poi.xssf.usermodel.XSSFWorkbook; //導入方法依賴的package包/類
public static XSSFWorkbook create(List<RaceResult> raceResults) {
XSSFWorkbook workbook = new XSSFWorkbook();
helper = workbook.getCreationHelper();
dateFormat = workbook.createCellStyle();
dateFormat.setDataFormat(helper.createDataFormat().getFormat("m/d/yy"));
twoDigitFormat = workbook.createCellStyle();
twoDigitFormat.setDataFormat(helper.createDataFormat().getFormat("0.00"));
threeDigitFormat = workbook.createCellStyle();
threeDigitFormat.setDataFormat(helper.createDataFormat().getFormat("0.000"));
commaNumberFormat = workbook.createCellStyle();
commaNumberFormat.setDataFormat(helper.createDataFormat().getFormat("#,##0"));
twoDigitCommaFormat = workbook.createCellStyle();
twoDigitCommaFormat.setDataFormat(helper.createDataFormat().getFormat("#,##0.00"));
createResultsSheets(raceResults, workbook);
createBreedingSheet(raceResults, workbook);
createWageringSheet(raceResults, workbook);
return workbook;
}
示例2: extractPicturePortion
import org.apache.poi.xssf.usermodel.XSSFWorkbook; //導入方法依賴的package包/類
/**
* 抽象出圖片生成業務代碼
*
* @throws IOException
*/
private void extractPicturePortion(String svgString, XSSFWorkbook wb,
XSSFSheet sheet, int startCol, int endCol, int startRow, int endRow)
throws IOException {
// 圖片
if (org.apache.commons.lang3.StringUtils.isNotBlank(svgString)) {
byte[] safeDataBytes = new BASE64Decoder().decodeBuffer(svgString);
int pictureIdx = wb.addPicture(safeDataBytes,
Workbook.PICTURE_TYPE_JPEG);
CreationHelper helper = wb.getCreationHelper();
// Create the drawing patriarch. This is the top level container for
// all shapes.
Drawing drawing = sheet.createDrawingPatriarch();
// add a picture shape
ClientAnchor anchor = helper.createClientAnchor();
// set top-left corner of the picture,
// subsequent call of Picture#resize() will operate relative to it
anchor.setCol1(startCol);
anchor.setCol2(endCol);
anchor.setRow1(startRow);
anchor.setRow2(endRow);
anchor.setDx1(0);
anchor.setDy1(0);
anchor.setDx2(0);
anchor.setDy2(0);
anchor.setAnchorType(ClientAnchor.MOVE_DONT_RESIZE);
Picture pict = drawing.createPicture(anchor, pictureIdx);
pict.resize(1);
}
}
示例3: exportExcelXLSX
import org.apache.poi.xssf.usermodel.XSSFWorkbook; //導入方法依賴的package包/類
public void exportExcelXLSX(String saveOption){
//run standard checks before exporting
if (!exportChecks(saveOption)) return;
JFileChooser jfc = new JFileChooser(System.getProperty("user.home"));
ExcelFileFilter eff = new ExcelFileFilter();
jfc.setFileFilter(eff);
String defaultName = desc.name.replace(":", "") + ".xlsx";
if(defaultName.contains("Data Table ")){
defaultName = defaultName.replace("Data Table ", "");
}
File f=new File(defaultName);
jfc.setSelectedFile(f);
do {
int c = jfc.showSaveDialog(null);
if (c==JFileChooser.CANCEL_OPTION||c==JFileChooser.ERROR_OPTION) return;
f = jfc.getSelectedFile();
if (f.exists()) {
c=JOptionPane.showConfirmDialog(null, "File Already Exists\nConfirm Overwrite");
if (c==JOptionPane.OK_OPTION)break;
if (c==JOptionPane.CANCEL_OPTION) return;
}
} while (f.exists());
try {
if (!f.getName().endsWith(".xlsx")){
System.out.println(f.getName());
JOptionPane.showMessageDialog(null, "Save did not complete. Must end in .xlsx. Try again.");
}else{
XSSFWorkbook xlsxWB = new XSSFWorkbook();
CreationHelper createHelper = xlsxWB.getCreationHelper();
XSSFSheet xlsxSheet1 = xlsxWB.createSheet("First Sheet");
Row row = null;
int[] ind;
if (saveOption.equals("selection")) {
ind = dataT.getSelectedRows();
} else if (saveOption.equals("plottable")) {
ind = getPlottableRows();
} else {
ind = new int[dataT.getRowCount()];
for (int i=0; i<dataT.getRowCount(); i++) ind[i] = i;
}
int xlsxCol = dataT.getColumnCount();
row = xlsxSheet1.createRow((0));
//don't include Plot column
for (int c=1; c<xlsxCol; c++){
String columnName = dataT.getColumnName(c);
row.createCell(c-1).setCellValue(columnName);
}
for (int r=1; r<=ind.length; r++){
row = xlsxSheet1.createRow((r));
for (int c=1; c<xlsxCol; c++){
Object o = dataT.getValueAt(ind[r-1], c);
String input1 = null;
if(o instanceof String && ((String)o).equals("NaN")){
o = "";
input1 = o.toString();
row.createCell(c-1).setCellValue(input1);
}else if(o instanceof String){
row.createCell(c-1).setCellValue((String)o);
}
}
}
FileOutputStream xlsxOut = new FileOutputStream(f);
xlsxWB.write(xlsxOut);
xlsxOut.close();
}
} catch (Exception ex){
ex.printStackTrace();
}
}