Reference to another Workbook"

From Documentation
Line 4: Line 4:
  
  
cells in one spreadsheet can references to another spreadsheet's book.
+
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.
  
steps:
+
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:
# import each book
 
# make a book series
 
# syntax
 
  
 +
'''<tt>=[BOOK_NAME]SHEET_NAME!CELL_REFERENCE</tt>'''
  
= example =
+
For example:
  
<source lang='java'>
+
<tt>=[sourceBook.xlsx]source!A2</tt>
//example code
+
 
 +
 
 +
 
 +
[[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


Reference to another Workbook





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


Essentials-reference-book.png


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});
		
		//...
	}
	
}