How to create an excel file in android

0 votes

I tried example Create an Excel Spreadsheet from this link Create an Excel spredsheet
and I am getting NullPointerException at workbook.write();, Using this I can create excel file on SD card, but when I open that excel file using MS office 2007 I am getting Unable to read file message
Here the stack trace, ExcelStudy is my activity that uses WriteExcel class

W/System.err(  235): java.lang.NullPointerException
W/System.err(  235):    at jxl.biff.StringHelper.getUnicodeBytes(StringHelper.java:133)
W/System.err(  235):    at jxl.biff.FontRecord.getData(FontRecord.java:289)
W/System.err(  235):    at jxl.biff.WritableRecordData.getBytes(WritableRecordData.java:71)
W/System.err(  235):    at jxl.write.biff.File.write(File.java:132)
W/System.err(  235):    at jxl.biff.Fonts.write(Fonts.java:110)
W/System.err(  235):    at jxl.write.biff.WritableWorkbookImpl.write(WritableWorkbookImpl.java:699)
W/System.err(  235):    at comm.study.code.WriteExcel.write(WriteExcel.java:49)
W/System.err(  235):    at comm.study.code.ExcelStudy.createExcelFile(ExcelStudy.java:64)
W/System.err(  235):    at comm.study.code.ExcelStudy$1.onClick(ExcelStudy.java:47)
W/System.err(  235):    at android.view.View.performClick(View.java:2364)
W/System.err(  235):    at android.view.View.onTouchEvent(View.java:4179)
W/System.err(  235):    at android.widget.TextView.onTouchEvent(TextView.java:6541)
W/System.err(  235):    at android.view.View.dispatchTouchEvent(View.java:3709)
W/System.err(  235):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
W/System.err(  235):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
W/System.err(  235):    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
W/System.err(  235):    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
W/System.err(  235):    at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
W/System.err(  235):    at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
W/System.err(  235):    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
W/System.err(  235):    at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
W/System.err(  235):    at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(  235):    at android.os.Looper.loop(Looper.java:123)
W/System.err(  235):    at android.app.ActivityThread.main(ActivityThread.java:4363)
W/System.err(  235):    at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(  235):    at java.lang.reflect.Method.invoke(Method.java:521)
W/System.err(  235):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
W/System.err(  235):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
W/System.err(  235):    at dalvik.system.NativeStart.main(Native Method)

Apr 4, 2022 in Database by gaurav
• 23,260 points
1,104 views

1 answer to this question.

0 votes
In Android, create Excel XLSX or XLS files.
Create a Workbook class object.
Using the Workbook. getWorksheets. obtain() method, you can access the worksheet you want.
Put the value in the worksheet's chosen cell using the cell's identifier, such as A1, B3, and so on.
Using the Workbook. save() method, save the workbook as an Excel file.
answered Apr 4, 2022 by Edureka
• 13,670 points

Related Questions In Database

0 votes
1 answer

How to generate the statement CREATE TABLE for an existing table in postgreSQL?

Generate table creation statement for an existing ...READ MORE

answered Feb 9, 2022 in Database by Neha
• 9,060 points
6,289 views
0 votes
1 answer

How to use xlrd for writing an excel file

In Python, you can read and write ...READ MORE

answered Mar 30, 2022 in Database by gaurav
• 23,260 points
2,715 views
0 votes
0 answers
0 votes
2 answers
0 votes
1 answer

How to load data of .csv file in MySQL Database Table?

At first, put the dataset in the ...READ MORE

answered Jul 5, 2019 in Database by Reshma
1,220 views
0 votes
1 answer

How to sort dates from Oldest to Newest in Excel?

Drag down the column to select the ...READ MORE

answered Feb 23, 2022 in Database by gaurav
• 23,260 points
4,923 views
0 votes
0 answers

How to get address, Column Name and Row Name of all marked rows in Excel table as rows in new worksheet

 need the row/column combinations marked with an ...READ MORE

Feb 24, 2022 in Database by Edureka
• 13,670 points
1,854 views
0 votes
0 answers

How to import JSON file to Excel without coding?

Let's say you have a file named input.json which ...READ MORE

Feb 24, 2022 in Database by Edureka
• 13,670 points
587 views
0 votes
1 answer

How to view the XML form of an Excel file?

Excel is a spreadsheet programme. Click File->Open in ...READ MORE

answered Mar 25, 2022 in Database by Edureka
• 13,670 points
5,627 views
0 votes
1 answer

How to download created excel file in node.js using exceljs

Download a sample Excel file using Node. ...READ MORE

answered Apr 4, 2022 in Database by Edureka
• 13,670 points
7,397 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP