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

  • Home
  • SEARCH
  • 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 6073415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:16:07+00:00 2026-05-23T10:16:07+00:00

I am creating Excel file on the basis of CSV file.for reading CSV file,i

  • 0

I am creating Excel file on the basis of CSV file.for reading CSV file,i am using Opencsv API and Apache POI.In my csv contain 65537 row.

class Test {
public static void main(String[] args) throws IOException {
    Workbook wb = new HSSFWorkbook();
    CreationHelper helper = wb.getCreationHelper();
    Sheet sheet = wb.createSheet("new sheet");

    CSVReader reader = new CSVReader(new FileReader("SampleData.csv"));
    String[] line;
    int r = 0;int count=0;
    while ((line = reader.readNext()) != null) {
        Row row = sheet.createRow((short) r++);
        count=count+1;
         System.out.println("count-"+count);
        for (int i = 0; i < line.length; i++)
            row.createCell(i)
               .setCellValue(helper.createRichTextString(line[i]));
    }

    // Write the output to a file
    FileOutputStream fileOut = new FileOutputStream("workbook.xls");
    wb.write(fileOut);
    fileOut.close();
}}

when i run this program it give me following error:

Exception in thread "main" java.lang.IllegalArgumentException: Invalid row number (-32768) outside allowable range (0..65535)at org.apache.poi.hssf.usermodel.HSSFRow.setRowNum(HSSFRow.java:232)
    at org.apache.poi.hssf.usermodel.HSSFRow.<init>(HSSFRow.java:86)
    at org.apache.poi.hssf.usermodel.HSSFRow.<init>(HSSFRow.java:70)
    at org.apache.poi.hssf.usermodel.HSSFSheet.createRow(HSSFSheet.java:205)
    at org.apache.poi.hssf.usermodel.HSSFSheet.createRow(HSSFSheet.java:71)
    at com.arosys.utilityclasses.Test.main(Test.java:23)Java Result: 1

I tried to trace how much row it support i found it only support 32768 and also tried for less number of row,it works nicely and create excel file.

please help me to sort out this problem,if my csv contain 65536 row then how i am bale to write excel file(Xls).

Thanks

  • 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-05-23T10:16:07+00:00Added an answer on May 23, 2026 at 10:16 am

    Why are you casting the row num to short in the following line

     Row row = sheet.createRow((short) r++);
    

    Leave it as int

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating Excel file download using NOPI libraries. I have lot of data
I'm creating an excel file using jxl. I'd like to name the sheets with
I'm creating a xml-file for display in Excel using _di_IXMLDocument. But for some tags
I am trying to create a csv file using python that is truly Excel-compatible
I wanted to read excel file so i did following steps. First creating .csv
I am creating an excel file output in c# using OWC11 components. The output
I am creating a copy of an Excel file using VBA. In the file,
In Java, we're using the following package to programmatically create excel documents: org.apache.poi.hssf If
Basically I need to insert a bunch of data to an Excel file. Creating
I'm creating excel spreadsheets for reports using the XML method, where you export a

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.