Poi problem

i have a problem with jakarta POI.
for (Iterator rows = sheet.rowIterator(); rows.hasNext();) {
               row = (HSSFRow) rows.next();
               // I want to check whether this row does contain any data or not ?
               i tried row!=null to check no data in this row ....but this does not work.
               can you suggest any alternative ?

check the number of cells in the row, and the content of each cell.
I've noticed that it sometimes returns empty rows and/or empty cells in rows when you'd expect to get nothing.
Whether due to the way Excel writes things or what I've never bothered to investigate in detail.

Similar Messages

  • POI problems

    I have a java program which would generate a statistic report (excel - POI) based on a given input file; this input file contains information of the server and these messages are logged using log4j. With the use of DailyRollingFileAppender, the file would roll over every night at 00:00, the problem is when I set up cron job to invoke this project everything at 00:15 and it simply generated a workbook with an empty sheet. The weird thing is that I had hard-coded the sheet name as "A" but the ouputted excel has the filename as the sheet name, does anybody
    know what is going on?
    Thanks in advance!

    Can u provide the part of the code which u feel is not working correctly. Cheers

  • POI getCellStyle and empty string problem

    I'm having a problem getting the style of a cell from and excel input file and setting to an output file.
    I also have a problem recognizing blank cells that are not null in the input file here is my code any help would be great.
    package Trace;
    import java.io.*;
    import org.apache.poi.hssf.usermodel.*;
    import org.apache.poi.hssf.util.HSSFColor;
    import java.util.StringTokenizer;
    import org.apache.poi.poifs.filesystem.*;
    import java.lang.Runtime;
    public class Converter1 {
         private static short bhyvb= 0;
         private static short foreground, background;
         private static String[][] cellGridOut;
         private static int numRows, numColumns, clock;
         private static POIFSFileSystem fs;
         private static HSSFWorkbook wbin, wbout;
         private static HSSFSheet sheetIn, sheetOut;
         private static HSSFRow rowIn, rowOut;
         private static HSSFCell cellIn, cellIn1, cellOut;
         private static FileOutputStream fileOut = null;
         private static String rowIterator, rowIterator1;
         private static HSSFCellStyle style, style1;
         public static void main(String[] args) {
              //Take in 2 inputs mandatory, Input Event Trace excel file and Time Interval respectively
              if (args.length != 1)System.err.println("Input Excel File"); 
              //Create a new POI file system and HSSF workbook with your excel input file
              InputStream input = Converter.class.getResourceAsStream(args[0]);
              try{
                   fs = new POIFSFileSystem(input);
                   wbin = new HSSFWorkbook(fs);
              }catch (Exception e){System.err.println("File input error");}
              wbout = new HSSFWorkbook();
              sheetIn = wbin.getSheetAt(0);
              numRows = sheetIn.getLastRowNum();//numRows=723
              style = wbout.createCellStyle();
              //style.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
              //style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
              //get number of columns
              rowIn = sheetIn.getRow(0);
              boolean done = false;
              int testNullPointer;
              numColumns=0;
              while(!done){
                   //System.out.println(ColumnInc);
                   cellIn = rowIn.getCell((short)numColumns);
                   numColumns+=1;
                   try{
                        testNullPointer = cellIn.getCellType();
                   }catch(NullPointerException npe){
                        done = true;
              numColumns-=1; //number of columns = 25
              converterIt();
              //Create new output file, if it exists delete it
              File myFile = new File("converted.xls"); 
              if(myFile.exists()){
                   myFile.delete();
              //Create new file output stream
              try {
                   fileOut = new FileOutputStream(myFile);
              } catch (IOException ioe) {}
              //write all conversion data to output file
              try{ 
                   wbout.write(fileOut);
                   fileOut.close();
              }catch (IOException ioe) {} 
         public static void converterIt(){
              boolean nextDone = false;
              boolean nextDone1 = false;
              for(int i=0; i<numColumns; i++){
                   clock =1;
                   rowIn = sheetIn.getRow(0);
                   cellIn = rowIn.getCell((short)i);
                   String getTopRow = cellIn.getStringCellValue();
                   sheetOut = wbout.createSheet(getTopRow+"_s"+i);
                   sheetOut.setColumnWidth((short)0, (short)(13 * 256));
                   sheetOut.setDefaultColumnWidth((short)25);
                   for(int j=0; j<=numRows; j++){
                        if(j==0){
                             rowIn = sheetIn.getRow(j);
                             cellIn = rowIn.getCell((short)i);
                             String temp2 = cellIn.getStringCellValue();
                             rowOut = sheetOut.createRow((short)j);
                             cellOut = rowOut.createCell((short)j);
                             cellOut.setCellValue(temp2);
                             cellOut = rowOut.createCell((short)(j+1));
                             cellOut.setCellValue("CLOCK");
                        if(j==1){
                             rowIn = sheetIn.getRow(j);
                             cellIn = rowIn.getCell((short)i);
                             double temp3 = cellIn.getNumericCellValue();
                             rowOut = sheetOut.createRow((short)j);
                             cellOut = rowOut.createCell((short)0);
                             cellOut.setCellValue(temp3);
                             cellOut = rowOut.createCell((short)1);
                             cellOut.setCellValue("");
                        nextDone=false;
                        nextDone1=false;
                        if(j>1){
                             rowIn = sheetIn.getRow(j);
                             try{
                                  cellIn = rowIn.getCell((short)i);
                             }catch(NullPointerException npe){
                                  rowIterator = "";
                                  nextDone=true;
                             if(!nextDone){
                                  try{
                                       rowIterator = cellIn.getStringCellValue();
                                       style = cellIn.getCellStyle();
                                  }catch(NullPointerException npe){}
                             if(j==2){
                                  rowOut = sheetOut.createRow((short)(clock+1));
                                  cellOut = rowOut.createCell((short)0);
                                  cellOut.setCellValue(rowIterator);
                                  cellOut = rowOut.createCell((short)1);
                                  cellOut.setCellValue(j-1);
                                  clock+=1;
                             }else{
                                  rowIn = sheetIn.getRow(j-1);
                                  try{
                                       cellIn = rowIn.getCell((short)i);
                                  }catch(NullPointerException npe){
                                       rowIterator1 = "";
                                       nextDone1=true;
                                  if(!nextDone){
                                       try{
                                            rowIterator1 = cellIn.getStringCellValue();
                                       }catch(NullPointerException npe){}
                             if(rowIterator1!=rowIterator && j>2){
                                  rowOut = sheetOut.createRow((short)clock+1);
                                  cellOut = rowOut.createCell((short)0);
                                  cellOut.setCellValue(rowIterator);
                                  //System.out.println(style);
                                  cellOut.setCellStyle(style);
                                  cellOut = rowOut.createCell((short)1);
                                  cellOut.setCellValue(j-1);
                                  clock+=1;
                        }//if
                   }//for
              }//for
         }//converterIt
    }//Converter1 CLASSEND

    I am not sure about the cell style as it looks like you are doing it right. For the null or blank cells it looks like you are only checking for null not "".

  • Problem with reading text from .DOC files through java and POI

    I have used a jar file "poi-scratchpad-3.2-FINAL-20081019.jar" and "poi-3.2-FINAL.jar" to read text from a .DOC file. I used the "getParagraphText()" function of the class "org.apache.poi.hwpf.extractor.WordExtractor" to get the text.
    I am able to get the text in the .DOC file but along with that i am getting the following messages/warnings
    Current policy properties
    *     thread.thread_num_limited: true*
    *     file.write.state: disabled*
    *     net.connect_ex_dom_list:*
    *     mmc.sess_cab_act.block_unsigned: false*
    *     mmc.sess_cab_act.action: validate*
    *     mmc.sess_pe_act.block_blacklisted: false*
    *     mmc.sess_pe_act.block_invalid: true*
    *     jscan.sess_applet_act.stub_out_blocked_applet: true*
    *     file.destructive.in_list:*
    *     jscan.sess_applet_act.block_all: false*
    *     file.write.in_list:*
    *     file.nondestructive.in_list:*
    *     window.num_limited: true*
    *     file.read.state: disabled*
    *     jscan.session.origin_uri: http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/poi/poi/3.2-FINAL/poi-3.2-FINAL.jar*
    *     file.nondestructive.state: disabled*
    *     jscan.session.user_ipaddr: 10.136.64.153*
    *     net.connect_other: false*
    *     thread.thread_num_max: 8*
    *     file.destructive.ex_list:*
    *     file.nondestructive.ex_list:*
    *     file.write.ex_list:*
    *     jscan.sess_applet_act.sig_invalid: block*
    *     file.read.in_list:*
    *     mmc.sess_cab_act.block_invalid: true*
    *     jscan.session.policyname: TU1DIERlZmF1bHQgUG9saWN5*
    *     mmc.sess_pe_act.action: validate*
    *     thread.threadgroup_create: false*
    *     net.connect_in_dom_list:*
    *     net.bind_enable: false*
    *     jscan.sess_applet_act.sig_trusted: pass*
    *     jscan.session.user_name: 10.166.64.201*
    *     jscan.session.user_hostname:*
    *     file.read.ex_list:*
    *     jscan.sess_applet_act.sig_blacklisted: block*
    *     jscan.session.daemon_protocol: http*
    *     net.connect_src: true*
    *     jscan.sess_applet_act.unsigned: instrument*
    *     mmc.sess_pe_act.block_unsigned: false*
    *     file.destructive.state: disabled*
    *     mmc.sess_cab_act.block_blacklisted: true*
    *     window.num_max: 5*
    Below the above messages/warnings the data is getting printed. Only the text part of the data is retrieved not the fonts, styles and bullets etc.
    Can anyone explain me why I am getting above warnings and how can I remove them. Is it possible to fetch the text depending on delimiters.
    Thanks in advance,
    Tiijnar
    Edited by: tiijnar on May 21, 2009 2:45 AM

    The jar files which were used are downloaded from http://jarfinder.com. Those jars created the problem of displaying those messages on console. I downloaded APIs from apache.org and used them in my application. Now my application is running good.
    Tiijnar

  • Problem with POI Powerpoint extraction

    Hello I am trying to extract text from a ppt file. I am using Coldfusion.
    Here is my code:
    <cfscript>
         function func_PPTToQueryStruct_POI() {
              var Files = "C:\CFusionMX7\wwwroot\google\Library\References\Army_UAV_brief.ppt";
              var fileIn             = CreateObject("java","java.io.FileInputStream").init(Files);
              var Extraction             = CreateObject("java","org.apache.poi.hslf.extractor.QuickButCruddyTextExtractor").init(fileIn);
              var Extraction1               = Extraction.getTextAsVector();
              return Extraction;
    </cfscript>The problem lies with this statement "var Extraction1 = Extraction.getTextAsVector();"
    I have successfully used this method with other jar previously yet I keep getting this error:
    "500 org.apache.poi.util.StringUtil.getFromUnicodeLE([B)Ljava/lang/String;"
    Is anyone familiar with using jar to extract text from ppt files?
    I appreciate it.

    Hi,
      Did u enter the right datasource name that you created in RSA3?
      So, pls check the correctness for the datasource name.
      Also, revisit the steps that you followed to create the Datasource.
    Thanks,
    Raj
    Message was edited by: Raj
    Message was edited by: Raj

  • POI HSSF XML to Excel DataFormat Problem

    Hiho,
    I�ve got the following problem:
    I want to create an Excel File from an XML File with POI and DOM4J. This works fine...
    Now I want to create some cells with a currency value in it, on which I want to calculate.
    Here�s my code:
    HSSFSheet sheet = wb.createSheet(s);
    HSSFDataFormat format = wb.createDataFormat();
    HSSFCellStyle intStyle = wb.createCellStyle();
    intStyle.setDataFormat(format.getFormat("(�#.##0,00);(�#.##0,00)"));
         for (cellit = rowelement.elementIterator(); cellit.hasNext();) {
              cellelement = (Element) cellit.next();
              String value = cellelement.getStringValue();
              cell = row.createCell(columnnum);
              s = cellelement.attributeValue("numeric");
              if (s != null) {
                   cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                   if (value != null)
                        cell.setCellValue(value);
                        cell.setCellStyle(intStyle);
       ...I always get a value with a prefixed apostrophe in Excel, which says that there�s an int value in a string cell (I think). Has anyone an idea whats wrong with my code? Thanks

    http://jakarta.apache.org/site/mail2.html#poi

  • Problem with method "write" in POI Library.

    Best regards, I have the following problem: I have a application in Oracle BPM 10g, that generates a file in Excel. First it upload a template, then query the data base, and storage this data in "POI Object" of type "XSSFWorkbook"; all of the this, at memory.
    The problem is when I try to write this object  "XSSFWorkbook", in the file(generate a Physical File), the file size is about 35 MB, usgin the method wb.write(out) of the "POI Library", my server spend about 15  minutes, generating blocks.
    I' like that some help me to solve this problem, maybe making any setting in my server.
    My Servers are:
    Application Server: Oracle WebLogic 10.3.1
    and File Server: Oracle Linux. Memoy: 32GB
    I show you the code in java:
                rsQuery = generarTablas(sStoredProcedure,xmlTableroControl);
                InputStream inp = JExcel.cargarPlantillaLectura(sRutaOrigen + sNombreOrigen + ".bck");
               XSSFWorkbook  wb = new XSSFWorkbook(inp);  //DESCOMENTAR
              wb.setForceFormulaRecalculation(true);
                int vnHoja = 0;
                String vsTabla = "";
                while(rsQuery.next()){
                    vnHoja  = rsQuery.getInt(1);
                    vsTabla = rsQuery.getString(2);
                    outResultado = new BufferedWriter (new FileWriter("/tmp/"+String.valueOf(nOrden)+vsTabla+".txt"));
                    outResultado.write("vsTabla: "+vsTabla+" Hoja : "+String.valueOf(vnHoja)+  "\n"+String.valueOf(Util.getTodayTime()));
                    outResultado.close();
                  nOrden ++;
                    this.rsConsulta = consultar(vsTabla);
                  if(_getRowCount(this.rsConsulta)>0)
                        generarHoja(wb, 6, vnHoja);
                        this.rsConsulta = null;//agregado 12/06/2013
                 File tempFileXLS = File.createTempFile(sNombreDestino + this.sFechaFin + "_", ".xlsx");
                ruta = sRutaDestino + tempFileXLS.getName();
                OutputStream out = new FileOutputStream(ruta);
                inp.close();
                wb.write(out);//---------------------> PROBLEM

    Best regards, I have the following problem: I have a application in Oracle BPM 10g, that generates a file in Excel. First it upload a template, then query the data base, and storage this data in "POI Object" of type "XSSFWorkbook"; all of the this, at memory.
    The problem is when I try to write this object  "XSSFWorkbook", in the file(generate a Physical File), the file size is about 35 MB, usgin the method wb.write(out) of the "POI Library", my server spend about 15  minutes, generating blocks.
    I' like that some help me to solve this problem, maybe making any setting in my server.
    My Servers are:
    Application Server: Oracle WebLogic 10.3.1
    and File Server: Oracle Linux. Memoy: 32GB
    I show you the code in java:
                rsQuery = generarTablas(sStoredProcedure,xmlTableroControl);
                InputStream inp = JExcel.cargarPlantillaLectura(sRutaOrigen + sNombreOrigen + ".bck");
               XSSFWorkbook  wb = new XSSFWorkbook(inp);  //DESCOMENTAR
              wb.setForceFormulaRecalculation(true);
                int vnHoja = 0;
                String vsTabla = "";
                while(rsQuery.next()){
                    vnHoja  = rsQuery.getInt(1);
                    vsTabla = rsQuery.getString(2);
                    outResultado = new BufferedWriter (new FileWriter("/tmp/"+String.valueOf(nOrden)+vsTabla+".txt"));
                    outResultado.write("vsTabla: "+vsTabla+" Hoja : "+String.valueOf(vnHoja)+  "\n"+String.valueOf(Util.getTodayTime()));
                    outResultado.close();
                  nOrden ++;
                    this.rsConsulta = consultar(vsTabla);
                  if(_getRowCount(this.rsConsulta)>0)
                        generarHoja(wb, 6, vnHoja);
                        this.rsConsulta = null;//agregado 12/06/2013
                 File tempFileXLS = File.createTempFile(sNombreDestino + this.sFechaFin + "_", ".xlsx");
                ruta = sRutaDestino + tempFileXLS.getName();
                OutputStream out = new FileOutputStream(ruta);
                inp.close();
                wb.write(out);//---------------------> PROBLEM

  • Problems in Using Jakarta POI in Jserv- NoClassDefFound

    Hi,
    I'm trying to deploy an application on Jserv which used the Jakarta's POI API. I placed the Jar file in the server folders and specified the same path in the file Jserv.properties.
    But then when trying to access that folder it gives the error NoClassDefFound for the poi's packages meaning its not picking up the classes under this jar.
    I restarted the Jserv several times after mentioning the path.
    Can anybody help me on this in pointing out wat i have missed here.
    Thanks in advance,
    Vijay

    hello,
    i'm also having problems using poi. I've copied the poi jar to tomcat/lib and also to the lib directory of the systems jdk. I've done the same with the commoms-logging.jar.
    Within a jsp is import these things:
    <code>
    <%@ page
         buffer="128"
         import="java.util.*,
              org.apache.poi.hssf.usermodel.*,
              org.apache.poi.hssf.util.*"
    %>
    </code>
    But when calling the url of the page i get:
    Package org.apache.poi.hssf.usermodel not found in import.
    Why, it is in the import? Whats wrong there?
    Thank you,
    Hava a nice day,
    Nico

  • Scusate io ho un iphone 3e ho problemi con la musica. riesco benissimo a metterla sull'iphone ma però mi da le canzoni mischiate, cioè ogni canzone parte, poi c'è un attimo di silenzio e riparte da un altro pezzo. come posso fare?

    scusate io ho un iphone 3e ho problemi con la musica. riesco benissimo a metterla sull'iphone ma però mi da le canzoni mischiate, cioè ogni canzone parte, poi c'è un attimo di silenzio e riparte da un altro pezzo. come posso fare? 10 PT

    Forse trovata soluzione, provate così:
    Fate il Backup di tutto
    Fate triplo-click sulla linea sottostante per selezionarla per intero:
    ~/Library/Application Support/SyncServices/
    Click destro o control-click sulla linea selezionata
    Selezionare "Mostra nel Finder" dal menu contestuale.
    Verrà individuata la cartella della riga sopra contenente un solo file.
    Chiudete iTunes.
    Spostate nel cestino il file contenuto nella cartella.
    Riaprite iTunes e provate la sincronizzazione.
    Good luck!

  • Ciao a tutti, se acquisto l'iphone 5 in inghilterra poi posso utilizzarlo senza problemi in italia x quanto riguarda garanzia e blocco della sim?

    devo fare un viaggio in inghilterra e pensavo di acquistarmi l'iphone 5, se torno in italia avrò problemi riguardo il blocco delle compagnie telefoniche e la garanzia? grazie in anticipo x le risposte

    Ciao a voi,ragazzi mio figlio vive in inghilterra e mi ha regalato un iphne 4s da un mese dopo averlo usato per un anno,poi lo ha resettato e spedito.
    Io ho inserito una Tim e lo uso senza aver avuto nessun problema.
    Il discorso cambia se acquisti un iphone in inghilterra,ma questo vale anche per tutti i paesi,se lo acquisti con un contratto di una compagnia telefonica inglese. A questo punto il telefono accetta solo quella sim,e se lo porti in Italia poi come fai a ricaricarlo. Lo puoi anche fare ma devi usare una carta di credito ma le telefonate ti verrebbero addebitate a te e a chi telefoni,perchè agiresti in roaming.  È come se telefonassi dall'Inghilterra.
    Tutto ok? Se hai necessità fammi sapere. Ciao Silvio

  • Ho problemi quando cercò di scaricare le applicazioni mi chiede tre domande di sicurezza e poi non funziona e non mi fa scaricare niente?...

    Ho problemi quando cercò di scaricare le applicazioni mi chiede tre domande di sicurezza e poi non funziona e non mi fa scaricare niente?...

    Si ha proprio dei problemi. Non riesco più a scaricare da iTunes, spero non mi abbiano preso i soldi per un download che dopo vari tentativi sembrava partito ma non vedo da nessuna parte

  • Ciao a tutti non riesco più a scaricare le app, mi dice che le scarica ma poi non le ho sul telefono... qualcuno ha lo stesso problema grazie???

    ciao a tutti non riesco più a scaricare le app, mi dice che le scarica ma poi non le ho sul telefono... qualcuno ha lo stesso problema grazie???
    iphone 4

    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • Buongiorno, il mio mac book pro  è lentissimo all'avvio, ci mette più di 2 minuto , e poi si impalla di continuo, con pause di 4-5 sec. vorrei sapere come poter risolvere questo problema. grazie

    buongiorno, il mio mac book pro  è lentissimo all'avvio, ci mette più di 2 minuto , e poi si impalla di continuo, con pause di 4-5 sec. vorrei sapere come poter risolvere questo problema. grazie

  • Struts \ POI \ Javascript Problem with IE 7

    Alright folks, I'm having a problem migrating my application from IE 6 to IE 7. We have search functionality in the app that triggers off of javascript calls when a button is pressed in the search. Once the data is retrieved, an export button becomes enabled that allows the user to export those results to Excel using POI. On the back end, we're using struts running in WAS 6. When the results are exported, the action class manually writes the excel workbook to the output stream as below:
         protected void print(HSSFWorkbook a_wb, HttpServletResponse a_response)
              throws IOException, ServletException {
              // generate output
              a_response.setContentType("application/vnd.ms-excel");
              ServletOutputStream out = a_response.getOutputStream();
              a_wb.write(out);
    Then the action returns null to signify to struts that the response has already been handled manually.
    Everything works perfectly in IE 6. In IE 7, however, everything is not so great. The search works to retrieve the results and I can export them to Excel. The problem is that after I export them to Excel, all the Javascript on my page ceases to work. Basically, what I've been able to determine is that upon receiving the Excel document response something is causing the document Javascript variable to become undefined. This causes all my javascript -- things like:
    document.getElementById('actionIndicator').value ="Clear";
    to completely fail because document is undefined. Mind you, the page is still sitting there rendered in IE, and I can do things like window.frames and programmatically see a list of the frames defined on the page -- but the document variable is completely gone.
    At this point I'm kind of at a loss as to what to check or test next, so I'm open to any suggestions. Thanks!

    Hey Gina
    we have not seen broken images like you did, but have seen dramatic reduction in respose time with IE 7 (~20 times slower than normal). A bunch of IT folks tried various settings and configurations, with no success. Finally, we figured that different versions of IE 7 acd differently. Version 5700 was running fine. Version 5713 (or something like that, the latest one) was slooooow.
    Our Office of Information Resources does not "support" any other browser than IE. So, in addition to problems with Office 2007 I described previously, we may get a double whammy from Microsoft. Don't get me started.
    Vojin

  • POI setFillBackgroundColor problem

    My background color keeps coming out black rather than the color I set. I'm using POI version 3.5 with Excel 2007.
         public void createWorkSheet(String model, String pcfg, String desc)
              try{
                   this.fileout = new FileOutputStream("container-sheet.xls");
                   this.wb = new HSSFWorkbook();
                   this.ws = wb.createSheet("Container Worksheet");
                   int size = 3000;
                   for(int x = 0; x < 6; x++)
                        this.ws.setColumnWidth(x, size);
                        size = (size == 3000) ? 4000 : 3000;
                   // index from 0,0 ... cell A1 is cell(0,0)
                   HSSFRow row1 = this.ws.createRow((short) 0);
                   HSSFCell cellA1 = row1.createCell((short) 0);
                   cellA1.setCellValue("Container:");
                   cellA1.setCellStyle(setBold());
                   HSSFCell cellB1 = row1.createCell((short) 1);
                   cellB1.setCellValue("TGHU0453616");
                   HSSFCell cellC1 = row1.createCell((short) 2);
                   cellC1.setCellValue("Date:");
                   cellC1.setCellStyle(setBold());
                   HSSFCell cellD1 = row1.createCell((short) 3);
                   cellD1.setCellValue(printDate());
                   HSSFCell cellE1 = row1.createCell((short) 4);
                   cellE1.setCellValue("Dock#");
                   cellE1.setCellStyle(setBold());
                   HSSFRow row2 = this.ws.createRow((short) 1);
                   HSSFCell cellA2 = row2.createCell((short) 0);
                   cellA2.setCellValue("PO#");
    //here is where I call the method to set the background color
                   cellA2.setCellStyle(setBoldBackgroundGrey());
                   this.wb.write(fileout);
                   fileout.flush();
                   fileout.close();
              }catch(Exception e){
                   e.printStackTrace();
    public HSSFCellStyle setBoldBackgroundGrey()
              HSSFCellStyle cellStyle = this.wb.createCellStyle();
              HSSFFont font = this.wb.createFont();
              font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
              cellStyle.setFont(font);
                    //below is where I set the color
              cellStyle.setFillBackgroundColor(HSSFColor.AQUA.index);
              cellStyle.setFillPattern(cellStyle.SOLID_FOREGROUND);
              return cellStyle;
         }

    For any people who stumble on this with the same problem the solution is to use setFillForegroundColor instead of setFillBackgroundColor. I guess if a big black blob in your cell is what your looking for setFillBackgroundColor is for you.

Maybe you are looking for