Error
j s <[email protected]> Thu, 17 Aug 2006 05:16:08 -0700
| Newsgroups | gmane.comp.windows.devel.jawin |
|---|---|
| Message-ID | <[email protected]> |
Hi .
Im trying to use jawin , for opening an excel workbook
, execute the macros and close the work book.
public void writeExcelToStream(String xlsFilePath,
OutputStream outStr, int noOfSheets)
throws Exception
{
try
{
Ole32.CoInitialize();
DispatchPtr excelApp = new
DispatchPtr("Excel.Application");
DispatchPtr workbooks =
(DispatchPtr)excelApp.get("Workbooks");
workbooks.invoke("Open", xlsFilePath);
DispatchPtr activeWorkbook =
(DispatchPtr)excelApp.get("ActiveWorkbook");
if(noOfSheets > 0)
{
for(int shNo=2; shNo <= noOfSheets; shNo++)
{
DispatchPtr tmpSheet =
(DispatchPtr)activeWorkbook.get("Sheets", new
Integer(shNo));
tmpSheet.invoke("Activate");
}
DispatchPtr tmpSheet =
(DispatchPtr)activeWorkbook.get("Sheets", new
Integer(1));
tmpSheet.invoke("Activate");
}
activeWorkbook.invoke("Save");
activeWorkbook.invoke("Close");
excelApp.invoke("Quit");
//Ole32.CoUninitialize();
File xlFile = new File(xlsFilePath);
byte[] xlsContent = getBytesFromFile(xlFile);
outStr.write(xlsContent);
xlsContent=null;
outStr.close();
xlFile.delete();
}
catch (COMException e) {
System.out.println("Got Expected Error: " + e);
}
catch(Exception ex){
logger.fatal("Write Excel to Stream operation
failed ", ex);
throw ex;
}
finally
{
Ole32.CoUninitialize();
}
}
This is the code I have used to open the workbook and
push the output back into Excel .
It works fine when one user logs in and view it .
Now if I have huge worksheet with a lot of data , come
across a lot of errors esp when there are 5 to 10
users trying to execute the same program from a web
front end . Any guidance on this will be helpful.
[com.symphonyrpm.applayer.common.util.JawinUtility]
[writeExcelToStream] [?] - Write Excel to Stream
operation failed
org.jawin.COMException: 800a03ec: Microsoft Office
Excel cannot access the file 'C:\Temp\temp'. There are
several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same
name as a currently open workbook.[src=Microsoft
Office
Excel,guid={00000000-0000-0000-0000-000000000000}]
at
org.jawin.marshal.GenericStub.dispatchInvoke0(Native
Method)
at
org.jawin.marshal.GenericStub.dispatchInvoke(GenericStub.java:201)
at
org.jawin.DispatchPtr.invokeN(DispatchPtr.java:587)
at
org.jawin.DispatchPtr.invokeN(DispatchPtr.java:555)
at org.jawin.DispatchPtr.invoke(DispatchPtr.java:501)
at
com.symphonyrpm.applayer.common.util.JawinUtility.writeExcelToStream(Unknown
Source)
at
com.symphonyrpm.applayer.workspace.util.ExportRenderer.exportPageToExcel(Unknown
Source)
at
com.symphonyrpm.applayer.workspace.action.ExportRendererAction.exportExcel(Unknown
Source)
at
com.symphonyrpm.applayer.workspace.action.ExportRendererAction.perform(Unknown
Source)
at
org.apache.struts.action.Action.execute(Action.java:420)
at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at
com.symphonyrpm.applayer.common.servlets.RPMBaseActionServlet.process(Unknown
Source)
at
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled
Code))
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled
Code))
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1239)
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java(Compiled
Code))
at
com.symphonyrpm.applayer.common.filters.ResponseHeaderFilter.doFilter(Unknown
Source)
at
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java(Compiled
Code))
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java(Compiled
Code))
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java(Compiled
Code))
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled
Code))
at
com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java(Compiled
Code))
at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compiled
Code))
at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compiled
Code))
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java(Compiled
Code))
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java(Compiled
Code))
at
com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java(Compiled
Code))
at
com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled
Code))
at
com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled
Code))
at
com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled
Code))
at
com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled
Code))
at
com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled
Code))
[8/17/06 15:41:31:236 IST] 000000a7 SystemOut O
FATAL {2006-08-17 15:41:31,236} [SERVER]
[com.symphonyrpm.applayer.workspace.util.ExportRenderer]
[exportPageToExcel] [?] - Error occured while
exporting page to excel
org.jawin.COMException: 800a03ec: Microsoft Office
Excel cannot access the file 'C:\Temp\temp'. There are
several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same
name as a currently open workbook.[src=Microsoft
Office
Excel,guid={00000000-0000-0000-0000-000000000000}]
at
org.jawin.marshal.GenericStub.dispatchInvoke0(Native
Method)
at
org.jawin.marshal.GenericStub.dispatchInvoke(GenericStub.java:201)
at
org.jawin.DispatchPtr.invokeN(DispatchPtr.java:587)
at
org.jawin.DispatchPtr.invokeN(DispatchPtr.java:555)
at org.jawin.DispatchPtr.invoke(DispatchPtr.java:501)
at
com.symphonyrpm.applayer.common.util.JawinUtility.writeExcelToStream(Unknown
Source)
at
com.symphonyrpm.applayer.workspace.util.ExportRenderer.exportPageToExcel(Unknown
Source)
at
com.symphonyrpm.applayer.workspace.action.ExportRendererAction.exportExcel(Unknown
Source)
at
com.symphonyrpm.applayer.workspace.action.ExportRendererAction.perform(Unknown
Source)
at
org.apache.struts.action.Action.execute(Action.java:420)
at
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at
com.symphonyrpm.applayer.common.servlets.RPMBaseActionServlet.process(Unknown
Source)
at
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled
Code))
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java(Compiled
Code))
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1239)
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java(Compiled
Code))
at
com.symphonyrpm.applayer.common.filters.ResponseHeaderFilter.doFilter(Unknown
Source)
at
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java(Compiled
Code))
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java(Compiled
Code))
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java(Compiled
Code))
at
com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled
Code))
at
com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java(Compiled
Code))
at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compiled
Code))
at
com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compiled
Code))
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java(Compiled
Code))
at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java(Compiled
Code))
at
com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java(Compiled
Code))
at
com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled
Code))
at
com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled
Code))
at
com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled
Code))
at
com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled
Code))
at
com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com