Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7762385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:23:19+00:00 2026-06-01T14:23:19+00:00

I was working on some fairly complex excel files and ran into a problem

  • 0

I was working on some fairly complex excel files and ran into a problem with copying sheets. Whenever I attempt to copy a sheet that is not completely blank i recieve the following message:

Exception in thread "main" java.lang.NullPointerException
     at jxl.write.biff.WritableSheetCopier.shallowCopyCells(WritableSheetCopier.java:499)
     at jxl.write.biff.WritableSheetCopier.copySheet(WritableSheetCopier.java:239)
     at jxl.write.biff.WritableSheetImpl.copy(WritableSheetImpl.java:1622)
     at jxl.write.biff.WritableWorkbookImpl.copySheet(WritableWorkbookImpl.java:987)
     at excelCalc.main(excelCalc.java:18)

I am wondering what the problem here is. Why would there even be a “.copySheet(” function if it couldnt be used for sheets with information in them. In an attempt to reproduce the problem on a more simple scale I created the code you see below. The output I would expect to see is 2 identical sheets with cell(0,0) having the label “test”. One sheet named “Flows” the other, “copy”. Any ideas as to why this is giving this null pointer?

import java.io.File;

import jxl.*;
import jxl.write.*;

public class excelCalc
{
    public static void main(String[] args) throws Exception
    {
        WritableWorkbook outputBook = Workbook.createWorkbook(new File("C:/Users/Kevin Brey/CS243/ExcelTest/files/output", "output.xls"));

        WritableSheet rSheet = outputBook.createSheet("Flows", 0);

        rSheet.addCell(new Label(0, 0, "test"));
        outputBook.copySheet(0, "copy", 0);
        outputBook.write();
        outputBook.close();
    }
}

EDIT:
This code also gives the same exception:

import java.io.File;

import jxl.*;
import jxl.write.*;

public class excelCalc
{
    public static void main(String[] args) throws Exception
    {
        WritableWorkbook outputBook = Workbook.createWorkbook(new File("C:/Users/Kevin Brey/CS243/ExcelTest/files/output", "output.xls"));

        WritableSheet sheet1 = outputBook.createSheet("Sheet1", 0);
        WritableSheet sheet2 = outputBook.createSheet("Sheet2", 1);

        sheet1.addCell(new Label(0, 0, "Label1"));
        sheet2.addCell(new Label(0, 0, "Label2"));

        outputBook.copySheet(0, "Copy", 1);

        outputBook.write();
        outputBook.close();
    }
}

One of my ideas of what could be wrong is that since a sheet is open and has been edited it cannot be copied. I really don’t know how to get around this though.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:23:20+00:00Added an answer on June 1, 2026 at 2:23 pm

    It’s a bug in jxl-2.6.12.jar, use jxl-2.6.10.jar instead.

    Details:

    typo ‘&&’ into ‘&’

    line 493 – line 504 in WritableSheetCopier.java

    if (c != null)
              {
                toSheet.addCell(c);
    
                // Cell.setCellFeatures short circuits when the cell is copied,
                // so make sure the copy logic handles the validated cells        
                if (c.getCellFeatures() != null &
                    c.getCellFeatures().hasDataValidation())
                {
                  validatedCells.add(c);
                }
              }
    

    line 540 – line 551 in WritableSheetCopier.java

    if (c != null)
              {
                toSheet.addCell(c);
    
                // Cell.setCellFeatures short circuits when the cell is copied,
                // so make sure the copy logic handles the validated cells        
                if (c.getCellFeatures() != null &
                    c.getCellFeatures().hasDataValidation())
                {
                  validatedCells.add(c);
                } 
              }
    

    line 990 – line 1001 in SheetCopier.java

    if (c != null)
              {
                toSheet.addCell(c);
    
                // Cell.setCellFeatures short circuits when the cell is copied,
                // so make sure the copy logic handles the validated cells
                if (c.getCellFeatures() != null &
                    c.getCellFeatures().hasDataValidation())
                {
                  validatedCells.add(c);
                }
              }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a Mac, with some fairly old files. Different files were created
I am working on a fairly complex Java application using Swing. On some occasions
I'm working some code that inserts csv rows into an SQLite database using Python.
Working on some code for a machine problem; we've just started working with pointers,
I'm converting some excel formulas to another system and need to do some fairly
I have a fairly complex multi-threaded Windows service working, but I can't figure out
The website I'm working on has some fairly complicated routing structures and we're experiencing
After working with a lot of GD recently (for some fairly large scale projects
I am working with a fairly complex solution in Visual Studio 2008. It contains
I'm working on some fairly computational intensive calculations that deal with numpy matrices and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.