org.apache.poi.ss.usermodel.HeaderFooter Java Examples

The following examples show how to use org.apache.poi.ss.usermodel.HeaderFooter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExcelExtractor.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static String _extractHeaderFooter(HeaderFooter hf) {
	StringBuffer text = new StringBuffer();

	if(hf.getLeft() != null) {
		text.append(hf.getLeft());
	}
	if(hf.getCenter() != null) {
		if(text.length() > 0)
			text.append("\t");
		text.append(hf.getCenter());
	}
	if(hf.getRight() != null) {
		if(text.length() > 0)
			text.append("\t");
		text.append(hf.getRight());
	}
	if(text.length() > 0)
		text.append("\n");

	return text.toString();
}
 
Example #2
Source File: PageHandler.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("rawtypes") 
private void processHeaderFooter( HandlerState state, Collection birtHeaderFooter, HeaderFooter poiHeaderFooter ) throws BirtException {
	boolean handledAsGrid = false;
	for( Object ftrObject : birtHeaderFooter ) {
		if( ftrObject instanceof ITableContent ) {
			ITableContent ftrTable = (ITableContent)ftrObject;
			if( ftrTable.getChildren().size() == 1 ) {
				Object child = ftrTable.getChildren().toArray()[ 0 ];
				if( child instanceof IRowContent ) {
					IRowContent row = (IRowContent)child;
					if( ftrTable.getColumnCount() <= 3 ) {
						Object[] cellObjects = row.getChildren().toArray();
						if( ftrTable.getColumnCount() == 1 ) {
							poiHeaderFooter.setLeft( contentAsString( state, cellObjects[ 0 ] ) );
							handledAsGrid = true;
						} else if( ftrTable.getColumnCount() == 2 ) {
							poiHeaderFooter.setLeft( contentAsString( state, cellObjects[ 0 ] ) );
							poiHeaderFooter.setRight( contentAsString( state, cellObjects[ 1 ] ) );
							handledAsGrid = true;
						} else if( ftrTable.getColumnCount() == 3 ) {
							poiHeaderFooter.setLeft( contentAsString( state, cellObjects[ 0 ] ) );
							poiHeaderFooter.setCenter( contentAsString( state, cellObjects[ 1 ] ) );
							poiHeaderFooter.setRight( contentAsString( state, cellObjects[ 2 ] ) );
							handledAsGrid = true;
						}
					}
				}
			}
		}
		if( ! handledAsGrid ) {
			poiHeaderFooter.setLeft( contentAsString( state, ftrObject ) );
		}
	}
}
 
Example #3
Source File: ExcelOOXMLDocument.java    From olat with Apache License 2.0 4 votes vote down vote up
private void extractHeaderFooter(final StringBuilder buffy, final HeaderFooter hf) {
    final String content = ExcelExtractor._extractHeaderFooter(hf);
    if (content.length() > 0) {
        buffy.append(content).append(' ');
    }
}
 
Example #4
Source File: ExcelHelp.java    From hy.common.report with Apache License 2.0 3 votes vote down vote up
/**
 * 复制页眉、页脚的文字信息
 * 
 * @author      ZhengWei(HY)
 * @createDate  2017-06-22
 * @version     v1.0
 *
 * @param i_FromHF
 * @param i_ToHF
 */
public final static void copyHeaderFooter(HeaderFooter i_FromHF ,HeaderFooter i_ToHF)
{
    i_ToHF.setLeft(  i_FromHF.getLeft());
    i_ToHF.setCenter(i_FromHF.getCenter());
    i_ToHF.setRight( i_FromHF.getRight());
}