You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by Zulfi Khan <zu...@yahoo.com.INVALID> on 2021/05/17 00:06:48 UTC

Excel Sheet: Sheet problem

Hi,I am getting error with Sheet. Following is my program, I have attached the image also. Somebody please guide me.
Zulfi.

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;

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

/**
 *
 * @author zulfi
 */

    }
    
}



Re: Excel Sheet: Sheet problem

Posted by Juan Algaba <ja...@colef.mx>.
You are missing the import statement for "Sheet"
If you click the light bulb with the red exclamation mark on the left
netbeans can fix it for you.

--
- Juan Algaba

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: Excel Sheet: Sheet problem

Posted by Zulfi Khan <zu...@yahoo.com.INVALID>.
 
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 <ca...@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 <zu...@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 <an...@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   

Re: Excel Sheet: Sheet problem

Posted by Carl Mosca <ca...@gmail.com>.
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 <zu...@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 <
> andreas@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 regards
> Andreas
>
>

-- 
Carl J. Mosca
-- 
Regards,
Carl

Re: Excel Sheet: Sheet problem

Posted by Zulfi Khan <zu...@yahoo.com.INVALID>.
 
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 <an...@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
  

Re: Excel Sheet: Sheet problem

Posted by Andreas Reichel <an...@manticore-projects.com>.
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 regards
Andreas