Permalink
Browse files

Added a method to list all worksheets in a particular spreadsheet

  • Loading branch information...
1 parent 2d352d6 commit 4323befe1c0814fce912bf02a4bfb264fc109068 @egonw egonw committed Jun 6, 2011
@@ -169,4 +169,40 @@ public StringMatrix loadWorksheet(String spreadsheet, String worksheet,
}
return matrix;
}
+
+ public List<String> listWorksheets(String spreadsheet)
+ throws BioclipseException {
+ List<SpreadsheetEntry> spreadsheets = getSpreadsheets();
+
+ SpreadsheetEntry sheet = null;
+ for (int i = 0; i < spreadsheets.size(); i++) {
+ SpreadsheetEntry entry = spreadsheets.get(i);
+ if (spreadsheet.equals(entry.getTitle().getPlainText())) {
+ sheet = entry;
+ }
+ }
+
+ if (spreadsheet == null) {
+ throw new BioclipseException(
+ "No spreadsheets with the name: " + spreadsheet
+ );
+ }
+
+ List<String> worksheetNames = new ArrayList<String>();
+
+ List<WorksheetEntry> worksheets;
+ try {
+ worksheets = sheet.getWorksheets();
+ } catch (Exception exception) {
+ throw new BioclipseException(
+ "Error while getting worksheets for: " + spreadsheet,
+ exception
+ );
+ }
+ for (WorksheetEntry worksheet : worksheets) {
+ worksheetNames.add(worksheet.getTitle().getPlainText());
+ }
+
+ return worksheetNames;
+ }
}
@@ -33,6 +33,12 @@
public List<String> listSpreadsheets() throws BioclipseException;
@PublishedMethod(
+ methodSummary="Lists the worksheets for the given spreadsheet.",
+ params="String spreadsheet"
+ )
+ public List<String> listWorksheets(String spreadsheet);
+
+ @PublishedMethod(
methodSummary="Downloads a worksheet from a spreadsheet.",
params="String spreadsheet, String worksheet"
)

0 comments on commit 4323bef

Please sign in to comment.