Jump to content
We've recently updated our Privacy Statement, available here ×

Problem with php excel export - text is broken up into a new line


hiasmann

Recommended Posts

Hello.

I have following problem with jasper and php export:

I export some lines (4000 - 20000) into an excel sheet with jasper reports.

In some lines it breaks up the text into a new line.

The length of the text is between 30 and 200 chars.

There is no \r\n or <br/> in it.

This also happens when i only export this line.

I attached an example how it looks like.

System configuration:

OS: Debian

PHP 5.3.x

Java 6

Code:
Jasper Report configuration:Export configuration:$JRExporterParameter = new \JavaClass("net.sf.jasperreports.engine.JRExporterParameter");$JRXlsExporterParameter = new \JavaClass("net.sf.jasperreports.engine.export.JRXlsAbstractExporterParameter");$xlsExporter = new \Java("net.sf.jasperreports.engine.export.JExcelApiExporter");$xlsExporter->setParameter($JRExporterParameter->JASPER_PRINT, $this->_jasperPrint);$xlsExporter->setParameter($JRExporterParameter->OUTPUT_FILE_NAME,  $this->_outputfile);$xlsExporter->setParameter($JRXlsExporterParameter->IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, new \Java("java.lang.Boolean", true));$xlsExporter->setParameter($JRXlsExporterParameter->IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, new \Java("java.lang.Boolean", true));$xlsExporter->setParameter($JRXlsExporterParameter->IS_WHITE_PAGE_BACKGROUND, new \Java("java.lang.Boolean", false));$xlsExporter->setParameter($JRXlsExporterParameter->IS_DETECT_CELL_TYPE, new \Java("java.lang.Boolean", true));$xlsExporter->exportReport();XLS sheet configuration:$mainElement = $doc->createElement('jasperReport');$mainElement->setAttribute('xmlns', 'http://jasperreports.sourceforge.net/jasperreports');$mainElement->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');$mainElement->setAttribute('xsi:schemaLocation', 'http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd');$mainElement->setAttribute('name', 'Sheet 1');$mainElement->setAttribute('columnCount', '1');$mainElement->setAttribute('printOrder', 'Vertical');$mainElement->setAttribute('orientation', 'Portrait');$mainElement->setAttribute('columnWidth', $width);$mainElement->setAttribute('columnSpacing', '0');$mainElement->setAttribute('leftMargin', '30');$mainElement->setAttribute('rightMargin', '30');$mainElement->setAttribute('topMargin', '20');$mainElement->setAttribute('bottomMargin', '20');$mainElement->setAttribute('pageWidth', $width + 60);$mainElement->setAttribute('pageHeight', 842);$mainElement->setAttribute('isTitleNewPage', 'false');$mainElement->setAttribute('isSummaryNewPage', 'false');Column configuration:$titleElement		= $doc->createElement('title');$titleBandElement	= $doc->createElement('band');$titleBandElement->setAttribute('height', 30);$titleElement->appendChild($titleBandElement);$mainElement->appendChild($titleElement);$detailElement		= $doc->createElement('detail');$detailBandElement	= $doc->createElement('band');$detailBandElement->setAttribute('height', 25);$detailElement->appendChild($detailBandElement);$mainElement->appendChild($detailElement);$elementX = 0;foreach ($dataDefinitionSelected as $selectedColumn) {		$rowWidth = $this->_getXLSRowWidth($selectedColumn['dataIndex'],$selectedColumn['exportWidth']);		$staticTextElement = $doc->createElement('staticText');		$reportElement = $doc->createElement('reportElement');	$reportElement->setAttribute('positionType', 'Float');	$reportElement->setAttribute('stretchType', 'RelativeToTallestObject');	$reportElement->setAttribute('style', 'columnHeaderStyle');	$reportElement->setAttribute('x', $elementX);	$reportElement->setAttribute('y', 0);	$reportElement->setAttribute('width', $rowWidth);	$reportElement->setAttribute('height', 25);	$staticTextElement->appendChild($reportElement);		$textElementElement = $doc->createElement('textElement');	$fontElement = $doc->createElement('font');	$fontElement->setAttribute('size', '12');	$textElementElement->appendChild($fontElement);	$staticTextElement->appendChild($reportElement);		$textElement = $doc->createElement('text');	$textElement->appendChild($doc->createCDATASection($selectedColumn['header']));	$staticTextElement->appendChild($textElement);		$titleBandElement->appendChild($staticTextElement);			$textFieldElement = $doc->createElement('textField');	$textFieldElement->setAttribute('isBlankWhenNull', 'true');	$textFieldElement->setAttribute('isStretchWithOverflow', 'true');		$reportElement = $doc->createElement('reportElement');	$reportElement->setAttribute('positionType', 'Float');	$reportElement->setAttribute('stretchType', 'RelativeToTallestObject');	$reportElement->setAttribute('x', $elementX);	$reportElement->setAttribute('y', 0);	$reportElement->setAttribute('width', $rowWidth);	$reportElement->setAttribute('height', 25);	$textFieldElement->appendChild($reportElement);		$textElementElement = $doc->createElement('textElement');	$fontElement = $doc->createElement('font');	$fontElement->setAttribute('size', '12');	$textElementElement->appendChild($fontElement);	$textFieldElement->appendChild($textElementElement);	$textFieldExpressionElement = $doc->createElement('textFieldExpression');	$textFieldExpressionElement->setAttribute('class', 'java.lang.String');	$textFieldExpressionElement->appendChild($doc->createCDATASection('$F{'.$selectedColumn['dataIndex'].'}'));	$textFieldElement->appendChild($textFieldExpressionElement);		$detailBandElement->appendChild($textFieldElement);		$elementX += $rowWidth;}
Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...