how to use Excel in android application - java

So, i building an application that doing that:
when the user write a name in edittext and click a button, i want the application to give the user some information about this name,
I have an Excel with that information, how can i add this Excel into my apk
And how can i read it from there? for each name his specific information..
the Excel look like that:
http://s18.postimg.org/ofcgudlk9/image.jpg
So for example, when the user write "android" in the edittext and click the button, i want a toast that will show "number: 1234 , more: good"
Any Idea?

you can use JExcelApi library to read or write to an Excel file , you have to put your excel somewhere in Sdcard then with jxl you can read or write to it.

Don't put the Excel file in your app.
You can export the excel file as a CSV file.
Then you can use the csv file with your app or you can use it to create a SQLite database and distribute it with your app.
The csv or SQLite file goes into the assets directory.
You can use OpenCSV to parse the CSV file.
To distribute an SQLite file with your app you can use SQLiteAssetsHelper.

I would prefer Json instead of using an excel or CSV file as suggested in other answers. With Json you can easily read and search through your data.
So here is the approach,
Convert your Excel to Json here -> http://shancarter.github.io/mr-data-converter/ Note: Just a service
that I found in Google. You may search for better services.
Now place the Json in /res/assets folder. If there is no assets folder then create it.
Now Load the Json at the start of your application. Google about parsing Json files, If you are not aware of it.
Whenever user enters something, Please search the Json and show the respective content.
Hope it helps.

you may try use POI HSSF/XSSF to just read the excel file.

Related

Displaying contents of an Excel file in a Java SWT GUI

I am developing a password manager within Eclipse and I am using Windowbuilder to help. I am using SWT, and am trying to make use of an Excel file which would store information such as usernames, passwords and additional notes
This is what I have so far when the program is launched
The left part, where there is a patch of white is where I want a menu to navigate through the Excel file, but I can not start that yet as I do not know how to actually display the Excel file. The area on the right which is not being used is where I want the information to be displayed
This is a sketch of what I would want it to be similar to
The Excel file can be any type, as long as it works with the GUI. Any help would be appreciated
one suggestion is to create a workbook with multiple sheets by the name of your menu like Gmail, accounts etc. then create columns by name of the information you want to store which would be website, username, password etc. Then Use apache POI to read the file in java. This Tutorial will help you in reading the excel file.
Regarding display of excel file, You can use Table Editor to display your data.

Adding data in Excel file without closing it

I am currently using Apache POI to enter data into Excel file. The only problem is I can not keep the file open if I have to append data to the same file. Are there any specific sample codes which would allow me to do so?
My basic requirement is to fetch Runtime data from a place (this I am able to do) and add it to the Excel sheet while the file is still open.
Any suggestions?
I don't think that this is possible without a C# addon or some kind of macro. You could write a simple C# addon for Excel that connects to your java programm and recieves the realtime data. The addon will write it to the spreadsheat then.

Using java to create excel file with a web query link

I want to create excel file from java (for example with Apache POI) that contains web query with link to my application but I couldn't find any reference for it. Is that possible?
I'll even settle for updating the link of a web query in an existing excel file.
Thank you.
What I finally did is to create an xlsx file with a temp connection. Then I opened the file using a zip reader and modified the connections.xml file inside and then I zipped the file again to xlsx.
Works like a charm.

Read excel file extension from struts control <s:file>

I want read contents of excel file selected using
. I am using POI 3.8. The problem is I am not able to identify
if this file is xls or xlsx. Please help
Why do you need to know?
Just use WorkbookFactory to load the excel file, and it'll autodetect for you. You then don't need to know, and your code remains completely generic between the two file formats.

Storing data in Excel file from an android application

My application generates data and i want to share this data, like transfer to my PC and work or send it to others as excel sheet.
Can we store data from an android application to a Excel sheet programatically ? Then how do we open and Excel file and write to it ?
In theory, libraries like Apache POI and JExcel should work on Adroid but there are some issues with them at this point.
Only option is to generate XL that can be read by Excel. Steps are:
Create an Excel file on PC with formatting that you need
Save that file as XML, Excel will insert Tags for formatting/ formulas
Write java code to generate similar XML file on Android
On Android, save this XML file on SD Card
Transfer the XML to PC and open that in Excel
Take a look at this tutorial, How to create file in SD-Card.

Categories