You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Narayanan <na...@tcs.com> on 2010/12/01 13:01:47 UTC

Embed string data to docx file in java

How to embed string data to docx file in java? or how to embed xml file to
docx in java?
please help!!!
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Embed-string-data-to-docx-file-in-java-tp3287560p3287560.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Problem with java heap space

Posted by Jon Svede <js...@yahoo.com>.
You need to make the PermGen space about 1/4 of the total heap. Right now you 
have set to use 1/2 which is too large.  If you want to use 512m as your heap 
size you need to lower your PermGen size to 128m.  You may also need to play 
with these settings.  You may need to increase your heap size to 1024m or 
larger.  You'll need to play around with it to figure out what works best for 
you, there usually isn't a one size fits all answer in these situations.  There 
are other parameters for tuning a JVM that you might need to change, but you may 
need to post those questions to a forum/distribution list related to tuning.

You might want to either test using a Java main() or else move the code to an 
actual server and skip the MyEclipse set up.  I know it's easy to do it the way 
you are, but on your desktop you may not have enough memory to do everything at 
once (run all your other apps and MyEclipse and Tomcat).

Jon




----- Original Message ----
From: Pablo Johnson <pj...@aasa.com.pe>
To: POI Users List <us...@poi.apache.org>
Sent: Fri, December 3, 2010 1:13:01 PM
Subject: Re: Problem with java heap space

Sorry the delay too..

i tried to put this
-Xms512m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=256m
on the tomcat 5.5 configuration inside 
MyEclipse.. and it works but it takes about 8 
minutes only for read the .xlsm file.
Is there any option?

thanks for your help.

At 17:49 02/12/2010, you wrote:
>Sorry for the delay in getting back to this. Be 
>sure to reply with your OS and
>JVM info.
>
>Yes, I'd do what Dave suggested below but I'd also tweak the PermGen space,
>again if you are using Sun's JVM.  If you are using another JVM (JRockit for
>example) the settings are different.
>
>
>If you keep getting the OOME, keep increasing 
>the -Xms and -Xmx values, try to
>keep the PermGen sizing to 1/4 of the total 
>allocation.  Eventually you should
>find a memory sizing that works for your spreadsheet.
>
>Jon
>
>
>----- Original Message ----
>From: David Fisher <df...@jmlafferty.com>
>To: POI Users List <us...@poi.apache.org>
>Sent: Thu, December 2, 2010 9:38:05 AM
>Subject: Re: Problem with java heap space
>
>Hi -
>
>If you are in unix then the typical way to set 
>these environment variables for
>Tomcat is in the setenv.sh script found in the 
>/bin directory and called by the
>catalina.sh script.
>
>We use Apache Tomcat 6.0.29 and Java SE 1.6.0_18.
>
>Here are some of the settings from out setenv.sh:
>
># You want lots of memory.
>JAVA_OPTS="$JAVA_OPTS -Xms1024M -Xmx1024M"
># If you are using Java 6 and multi-cores you want GC that does not block.
>JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC -XX:+PrintGCTimeStamps"
># You need to be "headless" for POI operations like setting column widths
>JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
># You probably want to be in server mode
>JAVA_OPTS="$JAVA_OPTS -server"
>
>Depending on your environment you might need 
>your admin to make these settings
>for you.
>
>Sorry that POI can take so much memory, but it is what it is.
>
>Regards,
>Dave
>
>On Dec 2, 2010, at 8:07 AM, Louis.Masters@log-net.com wrote:
>
> > Windows or *nix?  What version of tomcat?  For Windows, tomcat >5.5, there
> > is a configure option in your menu.  For all others, I think you need to
> > add the parms to a CATALINA_OPTS env variable.
> >
> > -Lou
> >
> >
> > Pablo Johnson <pj...@aasa.com.pe> wrote on 12/02/2010 10:21:58 AM:
> >
> >> Hi
> >>
> >> im using apache-tomcat
> >> im trying to do what jon Svede told me
> >>
> >> On the Sun JVM these are the -X and -XX args, something like this:
> >> -Xms1024m -Xmx1024 -XX:PermSize=256m -XX:MaxPermSize=256m
> >> You would need to do this in the start script of your
> >> Tomcat/WebLogic/WebSphere/etc container.
> >> Hope that helps,
> >> Jon
> >>
> >> but i dont know where and how to modify it..
> >> i dont know  how much memory is assigned to my
> >> java heap set to.. i think its 256.
> >>
> >> thanks
> >>
> >>
> >>
> >> At 10:12 02/12/2010, you wrote:
> >>> What's your java heap set to?
> >>>
> >>> Pablo Johnson <pj...@m1.aasa.com.pe> wrote on 12/02/2010 09:19:21
> > AM:
> >>>
> >>>> hello!
> >>>>
> >>>> i`m doing a web application and i`m having this problem:
> >>>>
> >>>>
> >>>>         java.lang.OutOfMemoryError: Java heap space
> >>>> org.apache.xmlbeans.impl.store.Cur.createElementXobj(Cur.java:257)
> >>>>         org.apache.xmlbeans.impl.store.Cur$CurLoadContext.
> >>>> startElement(Cur.java:2992)
> >>>>         org.apache.xmlbeans.impl.store.Locale$SaxHandler.
> >>>> startElement(Locale.java:3198)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
> >>>> reportStartTag(Piccolo.java:1082)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> >>>> parseAttributesNS(PiccoloLexer.java:1822)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> >>>> parseOpenTagNS(PiccoloLexer.java:1521)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> >>>> parseTagNS(PiccoloLexer.java:1362)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> >>>> parseXMLNS(PiccoloLexer.java:1293)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> >>>> parseXML(PiccoloLexer.java:1261)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> >>>> yylex(PiccoloLexer.java:4808)
> >>>>
> > org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
> >>>> yyparse(Piccolo.java:1400)
> >>>> org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
> >>>>         org.apache.xmlbeans.impl.store.Locale$SaxLoader.
> >>>> load(Locale.java:3439)
> >>>>         org.apache.xmlbeans.impl.store.Locale.
> >>>> parseToXmlObject(Locale.java:1270)
> >>>>         org.apache.xmlbeans.impl.store.Locale.
> >>>> parseToXmlObject(Locale.java:1257)
> >>>>         org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.
> >>>> parse(SchemaTypeLoaderBase.java:345)
> >>>>         org.openxmlformats.schemas.spreadsheetml.x2006.main.
> >>>> WorksheetDocument$Factory.parse(Unknown
> >>>> Source)
> >>>> org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:170)
> >>>>         org.apache.poi.xssf.usermodel.XSSFSheet.
> >>>> onDocumentRead(XSSFSheet.java:162)
> >>>>         org.apache.poi.xssf.usermodel.XSSFWorkbook.
> >>>> onDocumentRead(XSSFWorkbook.java:227)
> >>>>         org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:190)
> >>>>         org.apache.poi.xssf.usermodel.XSSFWorkbook.
> >>>> <init>(XSSFWorkbook.java:175)
> >>>>         org.apache.poi.ss.usermodel.WorkbookFactory.
> >>>> create(WorkbookFactory.java:63)
> >>>>
> > com.aasa.logic.DespieceLogic.trabajaPlantilla(DespieceLogic.java:449)
> >>>>         com.aasa.logic.DespieceLogic.
> >>>> trabajarAsignacion(DespieceLogic.java:76)
> >>>>         com.aasa.action.LisBandejaDespieceAction.
> >>>> descargaArchivo(LisBandejaDespieceAction.java:360)
> >>>>         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>>>         sun.reflect.NativeMethodAccessorImpl.
> >>>> invoke(NativeMethodAccessorImpl.java:39)
> >>>>         sun.reflect.DelegatingMethodAccessorImpl.
> >>>> invoke(DelegatingMethodAccessorImpl.java:25)
> >>>>         java.lang.reflect.Method.invoke(Method.java:592)
> >>>>         org.apache.struts.actions.DispatchAction.
> >>>> dispatchMethod(DispatchAction.java:274)
> >>>>
> >>>>
> >>>>
> >>>> I`m trying to open a .xlsm file with 2.06 mb. This is my code:
> >>>>
> >>>>            fileIn = new SmbFileInputStream(plantilla);
> >>>>         wb = WorkbookFactory.create(fileIn); // <------------this
> >>>> line is the problem
> >>>>
> >>>>         final Sheet sheetDespacho = wb.getSheet("DESPACHOS");
> >>>>         for (int i=0; i<lstDespacho.size();i++){
> >>>>         Row row = sheetDespacho.getRow(i);
> >>>>                 if (row == null){
> >>>>                 row = sheetDespacho.createRow(i);
> >>>>                 }
> >>>>                 Cell cell = row.getCell(0);
> >>>>                 if (cell == null){
> >>>>                 cell = row.createCell(0);
> >>>>                 }
> >>>>                 cell.setCellValue(new Integer(lstDespacho.get(i)));
> >>>>
> >>>>                 cell = row.getCell(1);
> >>>>                 if (cell == null){
> >>>>                 cell = row.createCell(1);
> >>>>                 }
> >>>>                 cell.setCellValue(i+1);
> >>>>         }
> >>>>
> >>>>
> >>>> is there any other way to open this file? because it always throw me
> >>>> that exception:
> >>>> javax.servlet.ServletException: Java heap space
> >>>>
> >>>> thanks.
> >>>
> >>>
> >>> __________ Information from ESET Mail Security,
> >>> version of virus signature database 5667 (20101202) __________
> >>>
> >>> The message was checked by ESET Mail Security.
> >>> http://www.eset.com
> >>>
> >>>
> >>>
> >>>
> >>> __________ Información de ESET NOD32 Antivirus,
> >>> versión de la base de firmas de virus 5667 (20101202) __________
> >>>
> >>> ESET NOD32 Antivirus ha comprobado este mensaje.
> >>>
> >>> http://www.eset.com
> >>
> >>           Pablo Johnson Rojas
> >> Corporación Aceros Arequipa S.A.
> >>     Departamento de Informática
> >>        pjohnson@aasa.com.pe
> >>
> >>  PAntes de imprimir este mensaje, asegúrese que
> >> sea necesario. El medio ambiente está en nuestras manos.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>For additional commands, e-mail: user-help@poi.apache.org
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>For additional commands, e-mail: user-help@poi.apache.org
>
>
>
>
>__________ Information from ESET Mail Security, 
>version of virus signature database 5668 (20101202) __________
>
>The message was checked by ESET Mail Security.
>http://www.eset.com
>
>
>
>__________ Información de ESET NOD32 Antivirus, 
>versión de la base de firmas de virus 5668 (20101202) __________
>
>ESET NOD32 Antivirus ha comprobado este mensaje.
>
>http://www.eset.com

           Pablo Johnson Rojas
Corporación Aceros Arequipa S.A.
     Departamento de Informática
        pjohnson@aasa.com.pe

  PAntes de imprimir este mensaje, asegúrese que 
sea necesario. El medio ambiente está en nuestras manos.



      

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Problem with java heap space

Posted by Pablo Johnson <pj...@aasa.com.pe>.
Sorry the delay too..

i tried to put this
-Xms512m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=256m
on the tomcat 5.5 configuration inside 
MyEclipse.. and it works but it takes about 8 
minutes only for read the .xlsm file.
Is there any option?

thanks for your help.

At 17:49 02/12/2010, you wrote:
>Sorry for the delay in getting back to this. Be 
>sure to reply with your OS and
>JVM info.
>
>Yes, I'd do what Dave suggested below but I'd also tweak the PermGen space,
>again if you are using Sun's JVM.  If you are using another JVM (JRockit for
>example) the settings are different.
>
>
>If you keep getting the OOME, keep increasing 
>the -Xms and -Xmx values, try to
>keep the PermGen sizing to 1/4 of the total 
>allocation.  Eventually you should
>find a memory sizing that works for your spreadsheet.
>
>Jon
>
>
>----- Original Message ----
>From: David Fisher <df...@jmlafferty.com>
>To: POI Users List <us...@poi.apache.org>
>Sent: Thu, December 2, 2010 9:38:05 AM
>Subject: Re: Problem with java heap space
>
>Hi -
>
>If you are in unix then the typical way to set 
>these environment variables for
>Tomcat is in the setenv.sh script found in the 
>/bin directory and called by the
>catalina.sh script.
>
>We use Apache Tomcat 6.0.29 and Java SE 1.6.0_18.
>
>Here are some of the settings from out setenv.sh:
>
># You want lots of memory.
>JAVA_OPTS="$JAVA_OPTS -Xms1024M -Xmx1024M"
># If you are using Java 6 and multi-cores you want GC that does not block.
>JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC -XX:+PrintGCTimeStamps"
># You need to be "headless" for POI operations like setting column widths
>JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
># You probably want to be in server mode
>JAVA_OPTS="$JAVA_OPTS -server"
>
>Depending on your environment you might need 
>your admin to make these settings
>for you.
>
>Sorry that POI can take so much memory, but it is what it is.
>
>Regards,
>Dave
>
>On Dec 2, 2010, at 8:07 AM, Louis.Masters@log-net.com wrote:
>
> > Windows or *nix?  What version of tomcat?  For Windows, tomcat >5.5, there
> > is a configure option in your menu.  For all others, I think you need to
> > add the parms to a CATALINA_OPTS env variable.
> >
> > -Lou
> >
> >
> > Pablo Johnson <pj...@aasa.com.pe> wrote on 12/02/2010 10:21:58 AM:
> >
> >> Hi
> >>
> >> im using apache-tomcat
> >> im trying to do what jon Svede told me
> >>
> >> On the Sun JVM these are the -X and -XX args, something like this:
> >> -Xms1024m -Xmx1024 -XX:PermSize=256m -XX:MaxPermSize=256m
> >> You would need to do this in the start script of your
> >> Tomcat/WebLogic/WebSphere/etc container.
> >> Hope that helps,
> >> Jon
> >>
> >> but i dont know where and how to modify it..
> >> i dont know  how much memory is assigned to my
> >> java heap set to.. i think its 256.
> >>
> >> thanks
> >>
> >>
> >>
> >> At 10:12 02/12/2010, you wrote:
> >>> What's your java heap set to?
> >>>
> >>> Pablo Johnson <pj...@m1.aasa.com.pe> wrote on 12/02/2010 09:19:21
> > AM:
> >>>
> >>>> hello!
> >>>>
> >>>> i`m doing a web application and i`m having this problem:
> >>>>
> >>>>
> >>>>         java.lang.OutOfMemoryError: Java heap space
> >>>> org.apache.xmlbeans.impl.store.Cur.createElementXobj(Cur.java:257)
> >>>>         org.apache.xmlbeans.impl.store.Cur$CurLoadContext.
> >>>> startElement(Cur.java:2992)
> >>>>         org.apache.xmlbeans.impl.store.Locale$SaxHandler.
> >>>> startElement(Locale.java:3198)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
> >>>> reportStartTag(Piccolo.java:1082)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> >>>> parseAttributesNS(PiccoloLexer.java:1822)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> >>>> parseOpenTagNS(PiccoloLexer.java:1521)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> >>>> parseTagNS(PiccoloLexer.java:1362)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> >>>> parseXMLNS(PiccoloLexer.java:1293)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> >>>> parseXML(PiccoloLexer.java:1261)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> >>>> yylex(PiccoloLexer.java:4808)
> >>>>
> > org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
> >>>>         org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
> >>>> yyparse(Piccolo.java:1400)
> >>>> org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
> >>>>         org.apache.xmlbeans.impl.store.Locale$SaxLoader.
> >>>> load(Locale.java:3439)
> >>>>         org.apache.xmlbeans.impl.store.Locale.
> >>>> parseToXmlObject(Locale.java:1270)
> >>>>         org.apache.xmlbeans.impl.store.Locale.
> >>>> parseToXmlObject(Locale.java:1257)
> >>>>         org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.
> >>>> parse(SchemaTypeLoaderBase.java:345)
> >>>>         org.openxmlformats.schemas.spreadsheetml.x2006.main.
> >>>> WorksheetDocument$Factory.parse(Unknown
> >>>> Source)
> >>>> org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:170)
> >>>>         org.apache.poi.xssf.usermodel.XSSFSheet.
> >>>> onDocumentRead(XSSFSheet.java:162)
> >>>>         org.apache.poi.xssf.usermodel.XSSFWorkbook.
> >>>> onDocumentRead(XSSFWorkbook.java:227)
> >>>>         org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:190)
> >>>>         org.apache.poi.xssf.usermodel.XSSFWorkbook.
> >>>> <init>(XSSFWorkbook.java:175)
> >>>>         org.apache.poi.ss.usermodel.WorkbookFactory.
> >>>> create(WorkbookFactory.java:63)
> >>>>
> > com.aasa.logic.DespieceLogic.trabajaPlantilla(DespieceLogic.java:449)
> >>>>         com.aasa.logic.DespieceLogic.
> >>>> trabajarAsignacion(DespieceLogic.java:76)
> >>>>         com.aasa.action.LisBandejaDespieceAction.
> >>>> descargaArchivo(LisBandejaDespieceAction.java:360)
> >>>>         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>>>         sun.reflect.NativeMethodAccessorImpl.
> >>>> invoke(NativeMethodAccessorImpl.java:39)
> >>>>         sun.reflect.DelegatingMethodAccessorImpl.
> >>>> invoke(DelegatingMethodAccessorImpl.java:25)
> >>>>         java.lang.reflect.Method.invoke(Method.java:592)
> >>>>         org.apache.struts.actions.DispatchAction.
> >>>> dispatchMethod(DispatchAction.java:274)
> >>>>
> >>>>
> >>>>
> >>>> I`m trying to open a .xlsm file with 2.06 mb. This is my code:
> >>>>
> >>>>            fileIn = new SmbFileInputStream(plantilla);
> >>>>         wb = WorkbookFactory.create(fileIn); // <------------this
> >>>> line is the problem
> >>>>
> >>>>         final Sheet sheetDespacho = wb.getSheet("DESPACHOS");
> >>>>         for (int i=0; i<lstDespacho.size();i++){
> >>>>         Row row = sheetDespacho.getRow(i);
> >>>>                 if (row == null){
> >>>>                 row = sheetDespacho.createRow(i);
> >>>>                 }
> >>>>                 Cell cell = row.getCell(0);
> >>>>                 if (cell == null){
> >>>>                 cell = row.createCell(0);
> >>>>                 }
> >>>>                 cell.setCellValue(new Integer(lstDespacho.get(i)));
> >>>>
> >>>>                 cell = row.getCell(1);
> >>>>                 if (cell == null){
> >>>>                 cell = row.createCell(1);
> >>>>                 }
> >>>>                 cell.setCellValue(i+1);
> >>>>         }
> >>>>
> >>>>
> >>>> is there any other way to open this file? because it always throw me
> >>>> that exception:
> >>>> javax.servlet.ServletException: Java heap space
> >>>>
> >>>> thanks.
> >>>
> >>>
> >>> __________ Information from ESET Mail Security,
> >>> version of virus signature database 5667 (20101202) __________
> >>>
> >>> The message was checked by ESET Mail Security.
> >>> http://www.eset.com
> >>>
> >>>
> >>>
> >>>
> >>> __________ Información de ESET NOD32 Antivirus,
> >>> versión de la base de firmas de virus 5667 (20101202) __________
> >>>
> >>> ESET NOD32 Antivirus ha comprobado este mensaje.
> >>>
> >>> http://www.eset.com
> >>
> >>           Pablo Johnson Rojas
> >> Corporación Aceros Arequipa S.A.
> >>     Departamento de Informática
> >>        pjohnson@aasa.com.pe
> >>
> >>  PAntes de imprimir este mensaje, asegúrese que
> >> sea necesario. El medio ambiente está en nuestras manos.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>For additional commands, e-mail: user-help@poi.apache.org
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>For additional commands, e-mail: user-help@poi.apache.org
>
>
>
>
>__________ Information from ESET Mail Security, 
>version of virus signature database 5668 (20101202) __________
>
>The message was checked by ESET Mail Security.
>http://www.eset.com
>
>
>
>__________ Información de ESET NOD32 Antivirus, 
>versión de la base de firmas de virus 5668 (20101202) __________
>
>ESET NOD32 Antivirus ha comprobado este mensaje.
>
>http://www.eset.com

           Pablo Johnson Rojas
Corporación Aceros Arequipa S.A.
     Departamento de Informática
         pjohnson@aasa.com.pe

  PAntes de imprimir este mensaje, asegúrese que 
sea necesario. El medio ambiente está en nuestras manos.

Re: Problem with java heap space

Posted by Jon Svede <js...@yahoo.com>.
Sorry for the delay in getting back to this. Be sure to reply with your OS and 
JVM info.

Yes, I'd do what Dave suggested below but I'd also tweak the PermGen space, 
again if you are using Sun's JVM.  If you are using another JVM (JRockit for 
example) the settings are different. 


If you keep getting the OOME, keep increasing the -Xms and -Xmx values, try to 
keep the PermGen sizing to 1/4 of the total allocation.  Eventually you should 
find a memory sizing that works for your spreadsheet.

Jon


----- Original Message ----
From: David Fisher <df...@jmlafferty.com>
To: POI Users List <us...@poi.apache.org>
Sent: Thu, December 2, 2010 9:38:05 AM
Subject: Re: Problem with java heap space

Hi -

If you are in unix then the typical way to set these environment variables for 
Tomcat is in the setenv.sh script found in the /bin directory and called by the 
catalina.sh script.

We use Apache Tomcat 6.0.29 and Java SE 1.6.0_18.

Here are some of the settings from out setenv.sh:

# You want lots of memory.
JAVA_OPTS="$JAVA_OPTS -Xms1024M -Xmx1024M"
# If you are using Java 6 and multi-cores you want GC that does not block.
JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC -XX:+PrintGCTimeStamps"
# You need to be "headless" for POI operations like setting column widths
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
# You probably want to be in server mode
JAVA_OPTS="$JAVA_OPTS -server"

Depending on your environment you might need your admin to make these settings 
for you.

Sorry that POI can take so much memory, but it is what it is.

Regards,
Dave

On Dec 2, 2010, at 8:07 AM, Louis.Masters@log-net.com wrote:

> Windows or *nix?  What version of tomcat?  For Windows, tomcat >5.5, there 
> is a configure option in your menu.  For all others, I think you need to 
> add the parms to a CATALINA_OPTS env variable.
> 
> -Lou
> 
> 
> Pablo Johnson <pj...@aasa.com.pe> wrote on 12/02/2010 10:21:58 AM:
> 
>> Hi
>> 
>> im using apache-tomcat
>> im trying to do what jon Svede told me
>> 
>> On the Sun JVM these are the -X and -XX args, something like this:
>> -Xms1024m -Xmx1024 -XX:PermSize=256m -XX:MaxPermSize=256m
>> You would need to do this in the start script of your
>> Tomcat/WebLogic/WebSphere/etc container.
>> Hope that helps,
>> Jon
>> 
>> but i dont know where and how to modify it..
>> i dont know  how much memory is assigned to my 
>> java heap set to.. i think its 256.
>> 
>> thanks
>> 
>> 
>> 
>> At 10:12 02/12/2010, you wrote:
>>> What's your java heap set to?
>>> 
>>> Pablo Johnson <pj...@m1.aasa.com.pe> wrote on 12/02/2010 09:19:21 
> AM:
>>> 
>>>> hello!
>>>> 
>>>> i`m doing a web application and i`m having this problem:
>>>> 
>>>> 
>>>>         java.lang.OutOfMemoryError: Java heap space
>>>> org.apache.xmlbeans.impl.store.Cur.createElementXobj(Cur.java:257)
>>>>         org.apache.xmlbeans.impl.store.Cur$CurLoadContext.
>>>> startElement(Cur.java:2992)
>>>>         org.apache.xmlbeans.impl.store.Locale$SaxHandler.
>>>> startElement(Locale.java:3198)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
>>>> reportStartTag(Piccolo.java:1082)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
>>>> parseAttributesNS(PiccoloLexer.java:1822)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
>>>> parseOpenTagNS(PiccoloLexer.java:1521)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
>>>> parseTagNS(PiccoloLexer.java:1362)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
>>>> parseXMLNS(PiccoloLexer.java:1293)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
>>>> parseXML(PiccoloLexer.java:1261)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
>>>> yylex(PiccoloLexer.java:4808)
>>>> 
> org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
>>>> yyparse(Piccolo.java:1400)
>>>> org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
>>>>         org.apache.xmlbeans.impl.store.Locale$SaxLoader.
>>>> load(Locale.java:3439)
>>>>         org.apache.xmlbeans.impl.store.Locale.
>>>> parseToXmlObject(Locale.java:1270)
>>>>         org.apache.xmlbeans.impl.store.Locale.
>>>> parseToXmlObject(Locale.java:1257)
>>>>         org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.
>>>> parse(SchemaTypeLoaderBase.java:345)
>>>>         org.openxmlformats.schemas.spreadsheetml.x2006.main.
>>>> WorksheetDocument$Factory.parse(Unknown
>>>> Source)
>>>> org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:170)
>>>>         org.apache.poi.xssf.usermodel.XSSFSheet.
>>>> onDocumentRead(XSSFSheet.java:162)
>>>>         org.apache.poi.xssf.usermodel.XSSFWorkbook.
>>>> onDocumentRead(XSSFWorkbook.java:227)
>>>>         org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:190)
>>>>         org.apache.poi.xssf.usermodel.XSSFWorkbook.
>>>> <init>(XSSFWorkbook.java:175)
>>>>         org.apache.poi.ss.usermodel.WorkbookFactory.
>>>> create(WorkbookFactory.java:63)
>>>> 
> com.aasa.logic.DespieceLogic.trabajaPlantilla(DespieceLogic.java:449)
>>>>         com.aasa.logic.DespieceLogic.
>>>> trabajarAsignacion(DespieceLogic.java:76)
>>>>         com.aasa.action.LisBandejaDespieceAction.
>>>> descargaArchivo(LisBandejaDespieceAction.java:360)
>>>>         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>         sun.reflect.NativeMethodAccessorImpl.
>>>> invoke(NativeMethodAccessorImpl.java:39)
>>>>         sun.reflect.DelegatingMethodAccessorImpl.
>>>> invoke(DelegatingMethodAccessorImpl.java:25)
>>>>         java.lang.reflect.Method.invoke(Method.java:592)
>>>>         org.apache.struts.actions.DispatchAction.
>>>> dispatchMethod(DispatchAction.java:274)
>>>> 
>>>> 
>>>> 
>>>> I`m trying to open a .xlsm file with 2.06 mb. This is my code:
>>>> 
>>>>            fileIn = new SmbFileInputStream(plantilla);
>>>>         wb = WorkbookFactory.create(fileIn); // <------------this
>>>> line is the problem
>>>> 
>>>>         final Sheet sheetDespacho = wb.getSheet("DESPACHOS");
>>>>         for (int i=0; i<lstDespacho.size();i++){
>>>>         Row row = sheetDespacho.getRow(i);
>>>>                 if (row == null){
>>>>                 row = sheetDespacho.createRow(i);
>>>>                 }
>>>>                 Cell cell = row.getCell(0);
>>>>                 if (cell == null){
>>>>                 cell = row.createCell(0);
>>>>                 }
>>>>                 cell.setCellValue(new Integer(lstDespacho.get(i)));
>>>> 
>>>>                 cell = row.getCell(1);
>>>>                 if (cell == null){
>>>>                 cell = row.createCell(1);
>>>>                 }
>>>>                 cell.setCellValue(i+1);
>>>>         }
>>>> 
>>>> 
>>>> is there any other way to open this file? because it always throw me
>>>> that exception:
>>>> javax.servlet.ServletException: Java heap space
>>>> 
>>>> thanks.
>>> 
>>> 
>>> __________ Information from ESET Mail Security, 
>>> version of virus signature database 5667 (20101202) __________
>>> 
>>> The message was checked by ESET Mail Security.
>>> http://www.eset.com
>>> 
>>> 
>>> 
>>> 
>>> __________ Información de ESET NOD32 Antivirus, 
>>> versión de la base de firmas de virus 5667 (20101202) __________
>>> 
>>> ESET NOD32 Antivirus ha comprobado este mensaje.
>>> 
>>> http://www.eset.com
>> 
>>           Pablo Johnson Rojas
>> Corporación Aceros Arequipa S.A.
>>     Departamento de Informática
>>        pjohnson@aasa.com.pe
>> 
>>  PAntes de imprimir este mensaje, asegúrese que 
>> sea necesario. El medio ambiente está en nuestras manos.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


      

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Problem with java heap space

Posted by David Fisher <df...@jmlafferty.com>.
Hi -

If you are in unix then the typical way to set these environment variables for Tomcat is in the setenv.sh script found in the /bin directory and called by the catalina.sh script.

We use Apache Tomcat 6.0.29 and Java SE 1.6.0_18.

Here are some of the settings from out setenv.sh:

# You want lots of memory.
JAVA_OPTS="$JAVA_OPTS -Xms1024M -Xmx1024M"
# If you are using Java 6 and multi-cores you want GC that does not block.
JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC -XX:+PrintGCTimeStamps"
# You need to be "headless" for POI operations like setting column widths
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"
# You probably want to be in server mode
JAVA_OPTS="$JAVA_OPTS -server"

Depending on your environment you might need your admin to make these settings for you.

Sorry that POI can take so much memory, but it is what it is.

Regards,
Dave

On Dec 2, 2010, at 8:07 AM, Louis.Masters@log-net.com wrote:

> Windows or *nix?  What version of tomcat?  For Windows, tomcat >5.5, there 
> is a configure option in your menu.  For all others, I think you need to 
> add the parms to a CATALINA_OPTS env variable.
> 
> -Lou
> 
> 
> Pablo Johnson <pj...@aasa.com.pe> wrote on 12/02/2010 10:21:58 AM:
> 
>> Hi
>> 
>> im using apache-tomcat
>> im trying to do what jon Svede told me
>> 
>> On the Sun JVM these are the -X and -XX args, something like this:
>> -Xms1024m -Xmx1024 -XX:PermSize=256m -XX:MaxPermSize=256m
>> You would need to do this in the start script of your
>> Tomcat/WebLogic/WebSphere/etc container.
>> Hope that helps,
>> Jon
>> 
>> but i dont know where and how to modify it..
>> i dont know  how much memory is assigned to my 
>> java heap set to.. i think its 256.
>> 
>> thanks
>> 
>> 
>> 
>> At 10:12 02/12/2010, you wrote:
>>> What's your java heap set to?
>>> 
>>> Pablo Johnson <pj...@m1.aasa.com.pe> wrote on 12/02/2010 09:19:21 
> AM:
>>> 
>>>> hello!
>>>> 
>>>> i`m doing a web application and i`m having this problem:
>>>> 
>>>> 
>>>>         java.lang.OutOfMemoryError: Java heap space
>>>> org.apache.xmlbeans.impl.store.Cur.createElementXobj(Cur.java:257)
>>>>         org.apache.xmlbeans.impl.store.Cur$CurLoadContext.
>>>> startElement(Cur.java:2992)
>>>>         org.apache.xmlbeans.impl.store.Locale$SaxHandler.
>>>> startElement(Locale.java:3198)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
>>>> reportStartTag(Piccolo.java:1082)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
>>>> parseAttributesNS(PiccoloLexer.java:1822)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
>>>> parseOpenTagNS(PiccoloLexer.java:1521)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
>>>> parseTagNS(PiccoloLexer.java:1362)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
>>>> parseXMLNS(PiccoloLexer.java:1293)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
>>>> parseXML(PiccoloLexer.java:1261)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
>>>> yylex(PiccoloLexer.java:4808)
>>>> 
> org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
>>>>         org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
>>>> yyparse(Piccolo.java:1400)
>>>> org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
>>>>         org.apache.xmlbeans.impl.store.Locale$SaxLoader.
>>>> load(Locale.java:3439)
>>>>         org.apache.xmlbeans.impl.store.Locale.
>>>> parseToXmlObject(Locale.java:1270)
>>>>         org.apache.xmlbeans.impl.store.Locale.
>>>> parseToXmlObject(Locale.java:1257)
>>>>         org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.
>>>> parse(SchemaTypeLoaderBase.java:345)
>>>>         org.openxmlformats.schemas.spreadsheetml.x2006.main.
>>>> WorksheetDocument$Factory.parse(Unknown
>>>> Source)
>>>> org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:170)
>>>>         org.apache.poi.xssf.usermodel.XSSFSheet.
>>>> onDocumentRead(XSSFSheet.java:162)
>>>>         org.apache.poi.xssf.usermodel.XSSFWorkbook.
>>>> onDocumentRead(XSSFWorkbook.java:227)
>>>>         org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:190)
>>>>         org.apache.poi.xssf.usermodel.XSSFWorkbook.
>>>> <init>(XSSFWorkbook.java:175)
>>>>         org.apache.poi.ss.usermodel.WorkbookFactory.
>>>> create(WorkbookFactory.java:63)
>>>> 
> com.aasa.logic.DespieceLogic.trabajaPlantilla(DespieceLogic.java:449)
>>>>         com.aasa.logic.DespieceLogic.
>>>> trabajarAsignacion(DespieceLogic.java:76)
>>>>         com.aasa.action.LisBandejaDespieceAction.
>>>> descargaArchivo(LisBandejaDespieceAction.java:360)
>>>>         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>         sun.reflect.NativeMethodAccessorImpl.
>>>> invoke(NativeMethodAccessorImpl.java:39)
>>>>         sun.reflect.DelegatingMethodAccessorImpl.
>>>> invoke(DelegatingMethodAccessorImpl.java:25)
>>>>         java.lang.reflect.Method.invoke(Method.java:592)
>>>>         org.apache.struts.actions.DispatchAction.
>>>> dispatchMethod(DispatchAction.java:274)
>>>> 
>>>> 
>>>> 
>>>> I`m trying to open a .xlsm file with 2.06 mb. This is my code:
>>>> 
>>>>            fileIn = new SmbFileInputStream(plantilla);
>>>>         wb = WorkbookFactory.create(fileIn); // <------------this
>>>> line is the problem
>>>> 
>>>>         final Sheet sheetDespacho = wb.getSheet("DESPACHOS");
>>>>         for (int i=0; i<lstDespacho.size();i++){
>>>>         Row row = sheetDespacho.getRow(i);
>>>>                 if (row == null){
>>>>                 row = sheetDespacho.createRow(i);
>>>>                 }
>>>>                 Cell cell = row.getCell(0);
>>>>                 if (cell == null){
>>>>                 cell = row.createCell(0);
>>>>                 }
>>>>                 cell.setCellValue(new Integer(lstDespacho.get(i)));
>>>> 
>>>>                 cell = row.getCell(1);
>>>>                 if (cell == null){
>>>>                 cell = row.createCell(1);
>>>>                 }
>>>>                 cell.setCellValue(i+1);
>>>>         }
>>>> 
>>>> 
>>>> is there any other way to open this file? because it always throw me
>>>> that exception:
>>>> javax.servlet.ServletException: Java heap space
>>>> 
>>>> thanks.
>>> 
>>> 
>>> __________ Information from ESET Mail Security, 
>>> version of virus signature database 5667 (20101202) __________
>>> 
>>> The message was checked by ESET Mail Security.
>>> http://www.eset.com
>>> 
>>> 
>>> 
>>> 
>>> __________ Información de ESET NOD32 Antivirus, 
>>> versión de la base de firmas de virus 5667 (20101202) __________
>>> 
>>> ESET NOD32 Antivirus ha comprobado este mensaje.
>>> 
>>> http://www.eset.com
>> 
>>           Pablo Johnson Rojas
>> Corporación Aceros Arequipa S.A.
>>     Departamento de Informática
>>         pjohnson@aasa.com.pe
>> 
>>  PAntes de imprimir este mensaje, asegúrese que 
>> sea necesario. El medio ambiente está en nuestras manos.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Problem with java heap space

Posted by Lo...@log-net.com.
Windows or *nix?  What version of tomcat?  For Windows, tomcat >5.5, there 
is a configure option in your menu.  For all others, I think you need to 
add the parms to a CATALINA_OPTS env variable.

-Lou


Pablo Johnson <pj...@aasa.com.pe> wrote on 12/02/2010 10:21:58 AM:

> Hi
> 
> im using apache-tomcat
> im trying to do what jon Svede told me
> 
> On the Sun JVM these are the -X and -XX args, something like this:
> -Xms1024m -Xmx1024 -XX:PermSize=256m -XX:MaxPermSize=256m
> You would need to do this in the start script of your
> Tomcat/WebLogic/WebSphere/etc container.
> Hope that helps,
> Jon
> 
> but i dont know where and how to modify it..
> i dont know  how much memory is assigned to my 
> java heap set to.. i think its 256.
> 
> thanks
> 
> 
> 
> At 10:12 02/12/2010, you wrote:
> >What's your java heap set to?
> >
> >Pablo Johnson <pj...@m1.aasa.com.pe> wrote on 12/02/2010 09:19:21 
AM:
> >
> > > hello!
> > >
> > > i`m doing a web application and i`m having this problem:
> > >
> > >
> > >          java.lang.OutOfMemoryError: Java heap space
> > > org.apache.xmlbeans.impl.store.Cur.createElementXobj(Cur.java:257)
> > >          org.apache.xmlbeans.impl.store.Cur$CurLoadContext.
> > > startElement(Cur.java:2992)
> > >          org.apache.xmlbeans.impl.store.Locale$SaxHandler.
> > > startElement(Locale.java:3198)
> > >          org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
> > > reportStartTag(Piccolo.java:1082)
> > >          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> > > parseAttributesNS(PiccoloLexer.java:1822)
> > >          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> > > parseOpenTagNS(PiccoloLexer.java:1521)
> > >          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> > > parseTagNS(PiccoloLexer.java:1362)
> > >          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> > > parseXMLNS(PiccoloLexer.java:1293)
> > >          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> > > parseXML(PiccoloLexer.java:1261)
> > >          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> > > yylex(PiccoloLexer.java:4808)
> > > 
org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
> > >          org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
> > > yyparse(Piccolo.java:1400)
> > > org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
> > >          org.apache.xmlbeans.impl.store.Locale$SaxLoader.
> > > load(Locale.java:3439)
> > >          org.apache.xmlbeans.impl.store.Locale.
> > > parseToXmlObject(Locale.java:1270)
> > >          org.apache.xmlbeans.impl.store.Locale.
> > > parseToXmlObject(Locale.java:1257)
> > >          org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.
> > > parse(SchemaTypeLoaderBase.java:345)
> > >          org.openxmlformats.schemas.spreadsheetml.x2006.main.
> > > WorksheetDocument$Factory.parse(Unknown
> > > Source)
> > > org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:170)
> > >          org.apache.poi.xssf.usermodel.XSSFSheet.
> > > onDocumentRead(XSSFSheet.java:162)
> > >          org.apache.poi.xssf.usermodel.XSSFWorkbook.
> > > onDocumentRead(XSSFWorkbook.java:227)
> > >          org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:190)
> > >          org.apache.poi.xssf.usermodel.XSSFWorkbook.
> > > <init>(XSSFWorkbook.java:175)
> > >          org.apache.poi.ss.usermodel.WorkbookFactory.
> > > create(WorkbookFactory.java:63)
> > > 
com.aasa.logic.DespieceLogic.trabajaPlantilla(DespieceLogic.java:449)
> > >          com.aasa.logic.DespieceLogic.
> > > trabajarAsignacion(DespieceLogic.java:76)
> > >          com.aasa.action.LisBandejaDespieceAction.
> > > descargaArchivo(LisBandejaDespieceAction.java:360)
> > >          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > >          sun.reflect.NativeMethodAccessorImpl.
> > > invoke(NativeMethodAccessorImpl.java:39)
> > >          sun.reflect.DelegatingMethodAccessorImpl.
> > > invoke(DelegatingMethodAccessorImpl.java:25)
> > >          java.lang.reflect.Method.invoke(Method.java:592)
> > >          org.apache.struts.actions.DispatchAction.
> > > dispatchMethod(DispatchAction.java:274)
> > >
> > >
> > >
> > > I`m trying to open a .xlsm file with 2.06 mb. This is my code:
> > >
> > >             fileIn = new SmbFileInputStream(plantilla);
> > >          wb = WorkbookFactory.create(fileIn); // <------------this
> > > line is the problem
> > >
> > >          final Sheet sheetDespacho = wb.getSheet("DESPACHOS");
> > >          for (int i=0; i<lstDespacho.size();i++){
> > >          Row row = sheetDespacho.getRow(i);
> > >                  if (row == null){
> > >                  row = sheetDespacho.createRow(i);
> > >                  }
> > >                  Cell cell = row.getCell(0);
> > >                  if (cell == null){
> > >                  cell = row.createCell(0);
> > >                  }
> > >                  cell.setCellValue(new Integer(lstDespacho.get(i)));
> > >
> > >                  cell = row.getCell(1);
> > >                  if (cell == null){
> > >                  cell = row.createCell(1);
> > >                  }
> > >                  cell.setCellValue(i+1);
> > >          }
> > >
> > >
> > > is there any other way to open this file? because it always throw me
> > > that exception:
> > > javax.servlet.ServletException: Java heap space
> > >
> > > thanks.
> >
> >
> >__________ Information from ESET Mail Security, 
> >version of virus signature database 5667 (20101202) __________
> >
> >The message was checked by ESET Mail Security.
> >http://www.eset.com
> >
> >
> >
> >
> >__________ Información de ESET NOD32 Antivirus, 
> >versión de la base de firmas de virus 5667 (20101202) __________
> >
> >ESET NOD32 Antivirus ha comprobado este mensaje.
> >
> >http://www.eset.com
> 
>            Pablo Johnson Rojas
> Corporación Aceros Arequipa S.A.
>      Departamento de Informática
>          pjohnson@aasa.com.pe
> 
>   PAntes de imprimir este mensaje, asegúrese que 
> sea necesario. El medio ambiente está en nuestras manos.

Re: Problem with java heap space

Posted by Pablo Johnson <pj...@aasa.com.pe>.
Hi

im using apache-tomcat
im trying to do what jon Svede told me

On the Sun JVM these are the -X and -XX args, something like this:
-Xms1024m -Xmx1024 -XX:PermSize=256m -XX:MaxPermSize=256m
You would need to do this in the start script of your
Tomcat/WebLogic/WebSphere/etc container.
Hope that helps,
Jon

but i dont know where and how to modify it..
i dont know  how much memory is assigned to my 
java heap set to.. i think its 256.

thanks



At 10:12 02/12/2010, you wrote:
>What's your java heap set to?
>
>Pablo Johnson <pj...@m1.aasa.com.pe> wrote on 12/02/2010 09:19:21 AM:
>
> > hello!
> >
> > i`m doing a web application and i`m having this problem:
> >
> >
> >          java.lang.OutOfMemoryError: Java heap space
> > org.apache.xmlbeans.impl.store.Cur.createElementXobj(Cur.java:257)
> >          org.apache.xmlbeans.impl.store.Cur$CurLoadContext.
> > startElement(Cur.java:2992)
> >          org.apache.xmlbeans.impl.store.Locale$SaxHandler.
> > startElement(Locale.java:3198)
> >          org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
> > reportStartTag(Piccolo.java:1082)
> >          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> > parseAttributesNS(PiccoloLexer.java:1822)
> >          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> > parseOpenTagNS(PiccoloLexer.java:1521)
> >          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> > parseTagNS(PiccoloLexer.java:1362)
> >          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> > parseXMLNS(PiccoloLexer.java:1293)
> >          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> > parseXML(PiccoloLexer.java:1261)
> >          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> > yylex(PiccoloLexer.java:4808)
> > org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
> >          org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
> > yyparse(Piccolo.java:1400)
> > org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
> >          org.apache.xmlbeans.impl.store.Locale$SaxLoader.
> > load(Locale.java:3439)
> >          org.apache.xmlbeans.impl.store.Locale.
> > parseToXmlObject(Locale.java:1270)
> >          org.apache.xmlbeans.impl.store.Locale.
> > parseToXmlObject(Locale.java:1257)
> >          org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.
> > parse(SchemaTypeLoaderBase.java:345)
> >          org.openxmlformats.schemas.spreadsheetml.x2006.main.
> > WorksheetDocument$Factory.parse(Unknown
> > Source)
> > org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:170)
> >          org.apache.poi.xssf.usermodel.XSSFSheet.
> > onDocumentRead(XSSFSheet.java:162)
> >          org.apache.poi.xssf.usermodel.XSSFWorkbook.
> > onDocumentRead(XSSFWorkbook.java:227)
> >          org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:190)
> >          org.apache.poi.xssf.usermodel.XSSFWorkbook.
> > <init>(XSSFWorkbook.java:175)
> >          org.apache.poi.ss.usermodel.WorkbookFactory.
> > create(WorkbookFactory.java:63)
> > com.aasa.logic.DespieceLogic.trabajaPlantilla(DespieceLogic.java:449)
> >          com.aasa.logic.DespieceLogic.
> > trabajarAsignacion(DespieceLogic.java:76)
> >          com.aasa.action.LisBandejaDespieceAction.
> > descargaArchivo(LisBandejaDespieceAction.java:360)
> >          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >          sun.reflect.NativeMethodAccessorImpl.
> > invoke(NativeMethodAccessorImpl.java:39)
> >          sun.reflect.DelegatingMethodAccessorImpl.
> > invoke(DelegatingMethodAccessorImpl.java:25)
> >          java.lang.reflect.Method.invoke(Method.java:592)
> >          org.apache.struts.actions.DispatchAction.
> > dispatchMethod(DispatchAction.java:274)
> >
> >
> >
> > I`m trying to open a .xlsm file with 2.06 mb. This is my code:
> >
> >             fileIn = new SmbFileInputStream(plantilla);
> >          wb = WorkbookFactory.create(fileIn); // <------------this
> > line is the problem
> >
> >          final Sheet sheetDespacho = wb.getSheet("DESPACHOS");
> >          for (int i=0; i<lstDespacho.size();i++){
> >          Row row = sheetDespacho.getRow(i);
> >                  if (row == null){
> >                  row = sheetDespacho.createRow(i);
> >                  }
> >                  Cell cell = row.getCell(0);
> >                  if (cell == null){
> >                  cell = row.createCell(0);
> >                  }
> >                  cell.setCellValue(new Integer(lstDespacho.get(i)));
> >
> >                  cell = row.getCell(1);
> >                  if (cell == null){
> >                  cell = row.createCell(1);
> >                  }
> >                  cell.setCellValue(i+1);
> >          }
> >
> >
> > is there any other way to open this file? because it always throw me
> > that exception:
> > javax.servlet.ServletException: Java heap space
> >
> > thanks.
>
>
>__________ Information from ESET Mail Security, 
>version of virus signature database 5667 (20101202) __________
>
>The message was checked by ESET Mail Security.
>http://www.eset.com
>
>
>
>
>__________ Información de ESET NOD32 Antivirus, 
>versión de la base de firmas de virus 5667 (20101202) __________
>
>ESET NOD32 Antivirus ha comprobado este mensaje.
>
>http://www.eset.com

           Pablo Johnson Rojas
Corporación Aceros Arequipa S.A.
     Departamento de Informática
         pjohnson@aasa.com.pe

  PAntes de imprimir este mensaje, asegúrese que 
sea necesario. El medio ambiente está en nuestras manos.

Re: Problem with java heap space

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
Please will you start a new thread for this question. It does not relate to
the search/replace functionality and it is likely that many list members
will overlook it for that reason.

Yours

Mark B
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Embed-string-data-to-docx-file-in-java-tp3287560p3289481.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Problem with java heap space

Posted by Lo...@log-net.com.
What's your java heap set to?

Pablo Johnson <pj...@m1.aasa.com.pe> wrote on 12/02/2010 09:19:21 AM:

> hello!
> 
> i`m doing a web application and i`m having this problem:
> 
> 
>          java.lang.OutOfMemoryError: Java heap space
> org.apache.xmlbeans.impl.store.Cur.createElementXobj(Cur.java:257)
>          org.apache.xmlbeans.impl.store.Cur$CurLoadContext.
> startElement(Cur.java:2992)
>          org.apache.xmlbeans.impl.store.Locale$SaxHandler.
> startElement(Locale.java:3198)
>          org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
> reportStartTag(Piccolo.java:1082)
>          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> parseAttributesNS(PiccoloLexer.java:1822)
>          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> parseOpenTagNS(PiccoloLexer.java:1521)
>          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> parseTagNS(PiccoloLexer.java:1362)
>          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> parseXMLNS(PiccoloLexer.java:1293)
>          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> parseXML(PiccoloLexer.java:1261)
>          org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.
> yylex(PiccoloLexer.java:4808)
> org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
>          org.apache.xmlbeans.impl.piccolo.xml.Piccolo.
> yyparse(Piccolo.java:1400)
> org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
>          org.apache.xmlbeans.impl.store.Locale$SaxLoader.
> load(Locale.java:3439)
>          org.apache.xmlbeans.impl.store.Locale.
> parseToXmlObject(Locale.java:1270)
>          org.apache.xmlbeans.impl.store.Locale.
> parseToXmlObject(Locale.java:1257)
>          org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.
> parse(SchemaTypeLoaderBase.java:345)
>          org.openxmlformats.schemas.spreadsheetml.x2006.main.
> WorksheetDocument$Factory.parse(Unknown 
> Source)
> org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:170)
>          org.apache.poi.xssf.usermodel.XSSFSheet.
> onDocumentRead(XSSFSheet.java:162)
>          org.apache.poi.xssf.usermodel.XSSFWorkbook.
> onDocumentRead(XSSFWorkbook.java:227)
>          org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:190)
>          org.apache.poi.xssf.usermodel.XSSFWorkbook.
> <init>(XSSFWorkbook.java:175)
>          org.apache.poi.ss.usermodel.WorkbookFactory.
> create(WorkbookFactory.java:63)
> com.aasa.logic.DespieceLogic.trabajaPlantilla(DespieceLogic.java:449)
>          com.aasa.logic.DespieceLogic.
> trabajarAsignacion(DespieceLogic.java:76)
>          com.aasa.action.LisBandejaDespieceAction.
> descargaArchivo(LisBandejaDespieceAction.java:360)
>          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>          sun.reflect.NativeMethodAccessorImpl.
> invoke(NativeMethodAccessorImpl.java:39)
>          sun.reflect.DelegatingMethodAccessorImpl.
> invoke(DelegatingMethodAccessorImpl.java:25)
>          java.lang.reflect.Method.invoke(Method.java:592)
>          org.apache.struts.actions.DispatchAction.
> dispatchMethod(DispatchAction.java:274)
> 
> 
> 
> I`m trying to open a .xlsm file with 2.06 mb. This is my code:
> 
>             fileIn = new SmbFileInputStream(plantilla);
>          wb = WorkbookFactory.create(fileIn); // <------------this 
> line is the problem
> 
>          final Sheet sheetDespacho = wb.getSheet("DESPACHOS");
>          for (int i=0; i<lstDespacho.size();i++){
>          Row row = sheetDespacho.getRow(i);
>                  if (row == null){
>                  row = sheetDespacho.createRow(i);
>                  }
>                  Cell cell = row.getCell(0);
>                  if (cell == null){
>                  cell = row.createCell(0);
>                  }
>                  cell.setCellValue(new Integer(lstDespacho.get(i)));
> 
>                  cell = row.getCell(1);
>                  if (cell == null){
>                  cell = row.createCell(1);
>                  }
>                  cell.setCellValue(i+1);
>          }
> 
> 
> is there any other way to open this file? because it always throw me 
> that exception:
> javax.servlet.ServletException: Java heap space
> 
> thanks. 

Problem with java heap space

Posted by Pablo Johnson <pj...@m1.aasa.com.pe>.
hello!

i`m doing a web application and i`m having this problem:


         java.lang.OutOfMemoryError: Java heap space
         org.apache.xmlbeans.impl.store.Cur.createElementXobj(Cur.java:257)
         org.apache.xmlbeans.impl.store.Cur$CurLoadContext.startElement(Cur.java:2992)
         org.apache.xmlbeans.impl.store.Locale$SaxHandler.startElement(Locale.java:3198)
         org.apache.xmlbeans.impl.piccolo.xml.Piccolo.reportStartTag(Piccolo.java:1082)
         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseAttributesNS(PiccoloLexer.java:1822)
         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseOpenTagNS(PiccoloLexer.java:1521)
         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseTagNS(PiccoloLexer.java:1362)
         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseXMLNS(PiccoloLexer.java:1293)
         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.parseXML(PiccoloLexer.java:1261)
         org.apache.xmlbeans.impl.piccolo.xml.PiccoloLexer.yylex(PiccoloLexer.java:4808)
         org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yylex(Piccolo.java:1290)
         org.apache.xmlbeans.impl.piccolo.xml.Piccolo.yyparse(Piccolo.java:1400)
         org.apache.xmlbeans.impl.piccolo.xml.Piccolo.parse(Piccolo.java:714)
         org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:3439)
         org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1270)
         org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1257)
         org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
         org.openxmlformats.schemas.spreadsheetml.x2006.main.WorksheetDocument$Factory.parse(Unknown 
Source)
         org.apache.poi.xssf.usermodel.XSSFSheet.read(XSSFSheet.java:170)
         org.apache.poi.xssf.usermodel.XSSFSheet.onDocumentRead(XSSFSheet.java:162)
         org.apache.poi.xssf.usermodel.XSSFWorkbook.onDocumentRead(XSSFWorkbook.java:227)
         org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:190)
         org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:175)
         org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:63)
         com.aasa.logic.DespieceLogic.trabajaPlantilla(DespieceLogic.java:449)
         com.aasa.logic.DespieceLogic.trabajarAsignacion(DespieceLogic.java:76)
         com.aasa.action.LisBandejaDespieceAction.descargaArchivo(LisBandejaDespieceAction.java:360)
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:592)
         org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)



I`m trying to open a .xlsm file with 2.06 mb. This is my code:

            fileIn = new SmbFileInputStream(plantilla);
         wb = WorkbookFactory.create(fileIn); // <------------this 
line is the problem

         final Sheet sheetDespacho = wb.getSheet("DESPACHOS");
         for (int i=0; i<lstDespacho.size();i++){
         Row row = sheetDespacho.getRow(i);
                 if (row == null){
                 row = sheetDespacho.createRow(i);
                 }
                 Cell cell = row.getCell(0);
                 if (cell == null){
                 cell = row.createCell(0);
                 }
                 cell.setCellValue(new Integer(lstDespacho.get(i)));

                 cell = row.getCell(1);
                 if (cell == null){
                 cell = row.createCell(1);
                 }
                 cell.setCellValue(i+1);
         }


is there any other way to open this file? because it always throw me 
that exception:
javax.servlet.ServletException: Java heap space

thanks. 

Re: Embed string data to docx file in java

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
The OP is likely no longer interested but I thought it worthwhile posting
this bit of code here as I have been able to make XWPF perform a
search/replace operation. As it stands, the code has been compiled/tested
against an early release of 3.7 but I cannot see why it should fail if used
with a more recent release. There are a number of obvious improvements that
could be made but it may be of interest to some other list members.

Here is the code

import java.io.*;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Enumeration;
import java.util.List;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;

/**
 * Demonstrates a VERY simple implementation of a search and replace
algortihm
 * for use with XWPF.
 *
 * @author Mark B
 */
public class SearchReplace {

    private File sourceFile = null;
    private Hashtable<String, String> srTerms = null;
    private XWPFDocument doc = null;

    /**
     * The constructor which opens the named Word file.
     *
     * @param filename An instance of the String class that encapsulates the
     *        name of and path to a Word (.docx) document.
     * @throws java.io.IOException Thrown if a problem is encountered
opening
     *         and InutStream onto the Word file.
     */
    public SearchReplace(String filename) throws IOException {
        InputStream is = null;
        try {
            this.sourceFile = new File(filename);
            // Verify the the Word document exists and can be read
            if(this.sourceFile.exists() || this.sourceFile.canRead()) {
                
                // Attach a FileInputStream to the Word document file
                // and read it's contents into memory.
                is = new FileInputStream(this.sourceFile);
                this.doc = new XWPFDocument(is);
                this.srTerms = new Hashtable<String, String>();
            }
            else {
                throw new IllegalArgumentException("The file " +
                        filename +
                        " is not accessible.");
            }
        }
        catch(IOException ioEx) {
            System.out.println("IOException thrown opening Word document.");
            throw new IOException(ioEx);
        }
        finally {
            try {
                is.close();
            }
            catch(IOException ioEx) {
                System.out.println("IOException thrown closing
InputStream.");
                throw new IOException(ioEx);
            }
        }
    }

    /**
     * Add a search term and it's associated replacement text using the
following
     * parameters.
     *
     * @param searchTerm An instance of the String class that encapsulates
the
     *        word or words that are to be searched for.
     * @param replacementText An instance of the String class that
encapsulates
     *        the word or words that will be substituted in place of the
search
     *        term wherevener it is found in the document's text.
     */
    public void addSearchTerm(String searchTerm, String replacementText) {
        // Simply add the search term and it's asociated replacement text
        // to the Hashtable that is used to store these pairings. Note that
        // no check is made to ensure that either parameter is present.
        this.srTerms.put(searchTerm, replacementText);
    }

    /**
     * Called to perform the search and replace operation. This method will
     * begin with the first character run in the first paragraph of text and
     * process each. through to the end of the document. The process is
     * essentially this;
     *
     * * Get a paragraph from the document.
     * * Get the runs of text from that paragraph.
     * * Enumerate through the keys in the search text/replacement term
Hashtable
     *   and check to see whether the search tearm (the key) can be found in
the
     *   run. If it can be found, replace the search term with it's
associated
     *   replacement text and write the results back into the run.
     * * Store the Word document away agin following processing.
     *
     * Note that there is currently no provision made for writing the
resulting
     * document away under a different file name. This would be a trivial
change
     * to make however.
     *
     * @throws java.io.FileNotFoundException Thrown if a problem occurs in
the
     *         underlying file system whilst trying to open a
FileOutputStream
     *         attached to the Word document.
     * @throws java.io.IOException Thrown if a problem occurs in the
underlying
     *         file system whilst trying to store the Word document away.
     */
    public void searchReplace() throws FileNotFoundException, IOException {

        // Recover an Iterator to step through the XWPFParagraph objects
        // 'contained' with the Word document.
        Iterator<XWPFParagraph> parasIter =
this.doc.getParagraphsIterator();
        Iterator<XWPFRun> runsIter = null;
        Enumeration<String> srchTermEnum = null;
        XWPFParagraph para = null;
        XWPFRun run = null;
        List<XWPFRun> runsList = null;
        String searchTerm = null;
        String runText = null;
        String replacementText = null;
        OutputStream os = null;

        // Step through the XWPFParagraph object one at a time.
        while(parasIter.hasNext()) {
            para = parasIter.next();

            // Recover a List of XWPFRun objects from the XWPFParagraph and
an
            // Iterator from this List.
            runsList = para.getRuns();
            runsIter = runsList.iterator();

            // Use the Iterator to step through the XWPFRun objects.
            while(runsIter.hasNext()) {
                
                // Get a run and it's text
                run = runsIter.next();
                runText = run.getText(0);

                // Recover an Enumeration object 'containing' the set of
                // search terms and then step through these terms looking
                // for match in the run's text
                srchTermEnum = this.srTerms.keys();
                while(srchTermEnum.hasMoreElements()) {
                   searchTerm = srchTermEnum.nextElement();

                   // If a match is found, use the replacement text to
substitute
                   // for the search term and update the runs text.
                   if(runText.contains(searchTerm)) {
                       replacementText = this.srTerms.get(searchTerm);

                       // Note the use of the replaceAll() method here. It
will,
                       // obviously, replace all occurrences of the search
term
                       // with the replacement text. This may not be what is
                       // required but is easy to modify by changing the
logic
                       // slightly and using the replaceFirst() or replace()
                       // methods.
                       runText = runText.replaceAll(searchTerm,
replacementText);
                       run.setText(runText, 0);
                   }
                }
            }
        }
        os = new FileOutputStream(this.sourceFile);
        this.doc.write(os);
    }
}

and here is one way to make use of it;

try {
            SearchReplace sr = new SearchReplace("C:\\temp\\Test.docx");
            sr.addSearchTerm("very", "extremely");
            sr.addSearchTerm("basic", "simple");
            sr.addSearchTerm("increase", "ramp up");
            sr.searchReplace();
}
catch(Exception ex) {
            System.out.println(ex.getClass().getName());
            System.out.println(ex.getMessage());
            ex.printStackTrace(System.out);
}
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Embed-string-data-to-docx-file-in-java-tp3287560p3289423.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Embed string data to docx file in java

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
To pre-empt Nick, no. POI cannot be used to manipulate macros in this manner;
the only way to accompilsh this sort of operation is to actually have the
macro engine - or some analogue - executing so that it can access the
macro's code along with the file and perform the required manipulations. May
I suggest that you look into using a library such as JACOB which would allow
you to access the OLE/COM functionality of Word. This will only work if you
are running on Windows however - OLE/COM being proprietary Microsoft
technologies. If you are running under UNIX/LINUX then you will be forced to
look into using the Wine project which promises to execute Windows only code
on these other platforms. It has been a long time since I even looked at the
project's website so I cannot promise how advanced/robust Wine currently is.

Yours

Mark B
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Embed-string-data-to-docx-file-in-java-tp3287560p3289061.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Embed string data to docx file in java

Posted by Narayanan <na...@tcs.com>.
Thanks Nick,

Actually i want to put string data in to doc macro and execute that macro
from java such that it will find key_word in doc and replace with string
data.

some thing like

string name = "Nick"

In doc: Thanks <NAME>

OUTPUT : Thanks Nick

please help out whether its possible in java. I don't want to do it by
reading the file and replace using java api (stream or poi). Since i have
some other requirement that can be done using macro only.
-- 
View this message in context: http://apache-poi.1045710.n5.nabble.com/Embed-string-data-to-docx-file-in-java-tp3287560p3288944.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Embed string data to docx file in java

Posted by Nick Burch <ni...@alfresco.com>.
On Wed, 1 Dec 2010, Narayanan wrote:
> How to embed string data to docx file in java?

If you use XWPF, you can add in new paragraphs, and then add a run of text 
to that. Will that do what you need?

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org