Reference to another Workbook"
From Documentation
Line 4: | Line 4: | ||
− | + | Spreadsheet supports external reference: a cell in one spreadsheet can reference to a cell of another spreadsheet. This feature is useful when you want to apply a different view for data but don't want to change original book. It also can be used when you want to merge data from multiple books. | |
− | + | Before using this feature, you should build a book series for all book models including source book and target one. Then, use the syntax below to reference cells inside book series: | |
− | |||
− | |||
− | |||
+ | '''<tt>=[BOOK_NAME]SHEET_NAME!CELL_REFERENCE</tt>''' | ||
− | + | For example: | |
− | <source lang='java'> | + | <tt>=[sourceBook.xlsx]source!A2</tt> |
− | // | + | |
+ | |||
+ | |||
+ | [[File:essentials-reference-book.png | center]] | ||
+ | |||
+ | |||
+ | <source lang='java' high='20'> | ||
+ | public class BookSeriesComposer extends SelectorComposer<Component> { | ||
+ | |||
+ | |||
+ | @Wire | ||
+ | Spreadsheet ss; | ||
+ | @Wire | ||
+ | Spreadsheet ss2; | ||
+ | |||
+ | @Override | ||
+ | public void doAfterCompose(Component comp) throws Exception { | ||
+ | super.doAfterCompose(comp); | ||
+ | buildBookSeries(); | ||
+ | } | ||
+ | |||
+ | |||
+ | private void buildBookSeries(){ | ||
+ | Book book1 = ss.getBook(); | ||
+ | Book book2 = ss2.getBook(); | ||
+ | |||
+ | BookSeriesBuilder.getInstance().buildBookSeries(new Book[]{book1,book2}); | ||
+ | |||
+ | //... | ||
+ | } | ||
+ | |||
+ | } | ||
</source> | </source> |
Revision as of 07:33, 22 July 2013
Spreadsheet supports external reference: a cell in one spreadsheet can reference to a cell of another spreadsheet. This feature is useful when you want to apply a different view for data but don't want to change original book. It also can be used when you want to merge data from multiple books.
Before using this feature, you should build a book series for all book models including source book and target one. Then, use the syntax below to reference cells inside book series:
=[BOOK_NAME]SHEET_NAME!CELL_REFERENCE
For example:
=[sourceBook.xlsx]source!A2
public class BookSeriesComposer extends SelectorComposer<Component> {
@Wire
Spreadsheet ss;
@Wire
Spreadsheet ss2;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
buildBookSeries();
}
private void buildBookSeries(){
Book book1 = ss.getBook();
Book book2 = ss2.getBook();
BookSeriesBuilder.getInstance().buildBookSeries(new Book[]{book1,book2});
//...
}
}