hi am trying to export large data to excell using XSSFWorkbook ,i have a code written but what to modify it to BigGridDemo
http://www.docjar.org/html/api/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java.html http://apache-poi.1045710.n5.nabble.com/HSSF-and-XSSF-memory-usage-some-numbers-td4312784.html this is my code import com.bea.common.security.xacml.context.Result; import com.sun.jmx.snmp.Timestamp; import java.io.FileNotFoundException; import java.io.IOException; import java.io.OutputStream; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.apache.poi.ss.usermodel.*; import javax.faces.context.FacesContext; //import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFDataFormat; //import org.apache.poi.hssf.usermodel.HSSFRow; //import org.apache.poi.hssf.usermodel.HSSFSheet; //import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.*; import org.apache.poi.hssf.util.HSSFColor; import oracle.adf.model.BindingContainer; import oracle.adf.model.BindingContext; import oracle.adf.model.binding.DCBindingContainer; import oracle.adf.model.binding.DCIteratorBinding; import oracle.adf.view.rich.component.rich.data.RichTable; import org.apache.poi.POIDocument; //import org.apache.poi import org.apache.poi.xssf.usermodel.XSSFWorkbook; //import org.apache.poi.hssf.usermodel.*; //import oracle.jbo.Row; import oracle.jbo.RowSetIterator; import oracle.jbo.ViewObject; import org.apache.myfaces.trinidad.model.CollectionModel; import org.apache.myfaces.trinidad.model.RowKeySet; import org.apache.myfaces.trinidad.model.RowKeySetImpl; import org.apache.poi.hssf.usermodel.HSSFRichTextString; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.POIXMLDocumentPart; import org.apache.poi.POIXMLDocument; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; public class PoiBean { RichTable CustomTable; public PoiBean() { } public static BindingContainer getBindingContainer() { //return (BindingContainer)JSFUtils.resolveExpression("#{bindings}"); return (BindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry(); } public static DCBindingContainer getDCBindingContainer() { return (DCBindingContainer)getBindingContainer(); } public void generateExcel(FacesContext facesContext, OutputStream outputStream) throws IOException { try { Workbook workbook = new XSSFWorkbook(); //or new HSSFWorkbook(); Sheet worksheet = workbook.createSheet("Fonts"); // Get all the rows of a iterator ///////////////////////////////////////////////////////////////////////////////////////////////////// DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry(); DCIteratorBinding dcIteratorBindings = bindings.findIteratorBinding("CustomClientView1Iterator"); Row rowss = worksheet.createRow(0); ViewObject yourVO= dcIteratorBindings.getViewObject(); // Get all the rows of a ViewObject RowSetIterator iter = yourVO.createRowSetIterator("CustomClient"); iter.reset(); int rowCounter = 0; while (iter.hasNext()){ Cell cell = null; oracle.jbo.Row row = iter.next(); //print header on first row in excel if (rowCounter == 0) { rowss = worksheet.createRow(rowCounter); int cellCounter = 0; for (String colName : row.getAttributeNames()) { cell = rowss.createCell(cellCounter); // cellA1.setCellValue(colName); cellCounter++; } } //print data from second row in excel rowCounter++; ////////////////////////////////////////////////////////////// //short j = 0; int cellCounter = 0; //excelrow = (HSSFRow)worksheet.createRow((int)i); rowss = worksheet.createRow(rowCounter); for (String colName : row.getAttributeNames()) { System.out.println("hello "+row.getAttribute(colName)); System.out.println("hello "+colName); cell = rowss.createCell(cellCounter); rowCounter++; /// cell.setCellValue(new HSSFRichTextString(rs.getS)); if(!isBlank(colName)){ if (colName.equalsIgnoreCase("CcnCode")) { cell.setCellValue(row.getAttribute(colName).toString()); System.out.println("colName "+colName+"row.getAttribute(colName).toString()"+row.getAttribute(colName).toString()); } } //logic for cell formatting else if (colName.equalsIgnoreCase("CcnName")) { cell.setCellValue(row.getAttribute(colName).toString()); } //make it double if you want and convert accordingly else if (colName.equalsIgnoreCase("CcnRegDate")){ cell.setCellValue(row.getAttribute(colName).toString()); } else if (colName.equalsIgnoreCase("CcnCancelDate")){ if(null!=row.getAttribute(colName)){ cell.setCellValue(row.getAttribute(colName).toString()); } } else if (colName.equalsIgnoreCase("CcnUndertaking")){ if(null!=row.getAttribute(colName)){ cell.setCellValue(row.getAttribute(colName).toString()); } } else if (colName.equalsIgnoreCase("CcnCode8")){ if(null!=row.getAttribute(colName)){ cell.setCellValue(row.getAttribute(colName).toString()); } } else cell.setCellValue(row.getAttribute(colName).toString()); cellCounter++; } worksheet.createFreezePane(0, 1, 0, 1); } workbook.write(outputStream); outputStream.flush(); } //} catch (Exception e) { e.printStackTrace(); } } how can i modify this code thanks in advance -- View this message in context: http://apache-poi.1045710.n5.nabble.com/exporting-data-to-excell-using-XSSFWorkbook-tp5715796.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
