Hi thanks Carl. I am still getting problem but now with workbook, I initialized 
it to null but i am performing an operation on workbook in the try-catch block 
but it is not initializing workbook. My code is gievn below. I dont have any 
other file in the project related to this this project.I dont have any already 
created excel sheet using the name "Test".
package com.mycompany.excelsheet1;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import org.apache.poi.ss.usermodel.Sheet;

/**
 *
 * @author zulfi
 */
public class mainExcelSheet1 {
    public static void main(String[] args){
        Workbook workbook=null;
        System.out.println("Test");
        try {
           workbook = new XSSFWorkbook(new FileInputStream("FILENAME"));
        }catch(Exception e){}
 
//Then you can assign Sheets accordingly, using getSheetAt() method. 
 
       Sheet sheet = workbook.getSheetAt(10);
       sheet.setColumnWidth(0, 6000);
       sheet.setColumnWidth(1, 4000);
        
        
        
        

/**
 *
 * @author zulfi
 */

    }
    
}

The exception is:
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit 
value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal 
(DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute 
(DefaultExecutor.java:166)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:982)
    at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:929)
    at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:457)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo 
(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject 
(LifecycleModuleBuilder.java:81)
    at 
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build
 (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute 
(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke 
(NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke 
(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced 
(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch 
(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode 
(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main 
(Launcher.java:347)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time:  1.583 s
Finished at: 2021-06-06T19:47:03-05:00
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec 
(default-cli) on project ExcelSheet1: Command execution failed.: Process exited 
with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.


Somebody please guide me.

Zulfi.


    On Tuesday, June 1, 2021, 4:27:00 AM CDT, Carl Mosca <carljmo...@gmail.com> 
wrote:  
 
 Perhaps you could make your code along with an example worksheet available in 
a publicly accessible (git) repo.  
It would be easier for someone to reproduce and debug the issue...assuming the 
answer that has already been provided is not applicable or unclear.  Otherwise, 
folks will have to help an issue or two at a time which will not be very 
efficient and a bit frustrating.
If the screen capture is still current, it appears that you're missing the 
import for the Sheet class.  From the Source menu, you can use "Fix imports" to 
add the needed import statement(s).
It's hard to tell if/where "workbook" is declared but it appears to be 
undefined or out of scope.



On Mon, May 31, 2021 at 6:56 PM Zulfi Khan <zulfi6...@yahoo.com.invalid> wrote:

 
Hi,I have sent my question to apache poi list but no body is replying. Please 
tell me the correct email address.
Zulfi.
    On Sunday, May 16, 2021, 7:11:38 PM CDT, Andreas Reichel 
<andr...@manticore-projects.com> wrote:  
 
 Hello Zulfi.
On Mon, 2021-05-17 at 00:06 +0000, Zulfi Khan wrote:
Sheet sheet = workbook.getSheetAt();

The Sheet Index is missing when calling getSheetAt( **** );Also this is the 
Netbeans list and you will better ask any question on the Apache POI list.
Best regardsAndreas
  


-- 
Carl J. Mosca-- 
Regards,
Carl   

Reply via email to