article

How to Load Visible Sheets & Skip Invisible Sheet while Loading Workbook in Android using Java

Email
Submitted on: 2/10/2016 8:59:03 AM
By: Sherazam  
Level: Intermediate
User Rating: Unrated
Compatibility: Java (JDK 1.4), Java (JDK 1.5)
Views: 17482
 
     This technical tip show how developers can add hyperlinks to link data inside an Excel file their Android applications using Aspose.Cell for Android. A hyperlink links two entities. Everybody is familiar with hyperlinks because they are used extensively on the Internet. Using Aspose.Cells, developers can create different kinds of hyperlinks in Excel files. This article discusses what types of hyperlinks are supported in Aspose.Cells and how to use them.

 
				This technical tip show how developers can Load Visible Sheets Only and Skip Invisible Sheet while Loading Workbook inside Android applications. While loading a Workbook sometimes you may only need data in visible worksheets in a workbook. Aspose.Cells allows you to skip data in invisible worksheets while loading a workbook. The class LoadDataOptions provides a property OnlyVisibleWorksheet which allows us to skip invisible sheets. The sheets will be loaded, but all cell values will remain null.
// The following code demonstrates how to load visible sheets only.
File sdDir = Environment.getExternalStorageDirectory();
String sdPath = sdDir.getCanonicalPath();
String filePath = sdPath + "/Sample.out.xlsx"
// Create a sample workbook
// and put some data in first cell of all 3 sheets
Workbook createWorkbook = new Workbook();
createWorkbook.getWorksheets().get("Sheet1").getCells().get("A1").setValue("Aspose");
createWorkbook.getWorksheets().add("Sheet2").getCells().get("A1").setValue("Aspose");
createWorkbook.getWorksheets().add("Sheet3").getCells().get("A1").setValue("Aspose");
// Keep Sheet3 invisible
createWorkbook.getWorksheets().get("Sheet3").setVisible(false);
createWorkbook.save(samplePath);
// Load the sample workbook
LoadDataOption loadDataOption = new LoadDataOption();
loadDataOption.setOnlyVisibleWorksheet(true);
LoadOptions loadOptions = new LoadOptions();
loadOptions.setLoadDataAndFormatting(true);
loadOptions.setLoadDataOptions(loadDataOption);
Workbook loadWorkbook = new Workbook(samplePath, loadOptions);
System.out.println("Sheet1: A1: " + loadWorkbook.getWorksheets().get("Sheet1").getCells().get("A1").getValue());
System.out.println("Sheet2: A1: " + loadWorkbook.getWorksheets().get("Sheet2").getCells().get("A1").getValue());
System.out.println("Sheet3: A1: " + loadWorkbook.getWorksheets().get("Sheet3").getCells().get("A1").getValue());
System.out.println("Data is not loaded from invisible sheet");
 
Overview: Aspose.Cells for Android
Aspose.Cells for Android is a MS Excel spreadsheet component that allows programmer to develop android applications for reading, writing & manipulate Excel spreadsheets (XLS, XLSX, XLSM, SpreadsheetML, CSV, tab delimited) and HTML file formats without needing to rely on Microsoft Excel. It supports robust formula calculation engine, pivot tables, VBA, workbook encryption, named ranges, custom charts, spreadsheet formatting, drawing objects like images, OLE objects & importing or creating charts.


Other 6 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.