Export – field with CR LF does not export data

QuestionsExport – field with CR LF does not export data
Francine asked 9 years ago

I have some fields that contains CRLF and when I export to CSV those fields are empty or contains only the data before the first CRLF.
If I try to export to Excel it says that the file is corrupted.

10 Answers
Abu Ghufran answered 9 years ago

Ok, i'll be updating you after generating the case.

Abu Ghufran answered 9 years ago

There seems to be some known issue with tcpdf library that we are using.
You can use the PDF based on html renderer and it does not have such issue, fallback is it's not very good for big datasets.
CSV export is also working as exptected.

PDF: http://www.phpgrid.org/demo/demos/export/export-pdf-html.phps
Screen: http://prntscr.com/al8u70

CSV: http://www.phpgrid.org/demo/demos/export/export-csv.phps
Screen: http://prntscr.com/al8y8b

Abu Ghufran answered 9 years ago

In PDF code, refer the nl2br function in html renderer callback.

Abu Ghufran answered 9 years ago

To fix in default pdf lib, you need to edit lib/inc/tcpdf/class.TCPDF.EasyTable.php

replace;
$this->MultiCell($cellWidth, $cellHeight,$cellText, 1, $textAlign, $this->_FillCell, 0, '', '', true, 0, false, true, $cellHeight);

with:
$this->MultiCell($cellWidth, $cellHeight,$cellText, 1, $textAlign, $this->_FillCell, 0, '', '', true, 0, true, true, $cellHeight);

note: true, 0, false -> true, 0, true

Francine answered 9 years ago

Thanks for the info for PDF export.

My problem is with Excel and csv export. When I populate my data in a temp data I add n between data for each line in the field that is setup as Text type. I have also tried to put rn but still doesn't export after first line.

Do you need my sample database data to try it? Also please note that I do not use yet version 2 of phpgrid.

Abu Ghufran answered 9 years ago

Please email me sample data at [email protected]
Also email me screenshots of the issue you are facing.

Francine answered 9 years ago

A got it to work for csv but I am still getting an error with Excel: It says that the file is in a different format than specified by the file extension and after clicking Yes to continue,it says that the file cannot be opened. I will email you the table sample data.

Abu Ghufran answered 9 years ago

Emailed you a phpexcel working demo.

For others:
Download PHPExcel lib from codeplex, and extract in lib/inc/excel. (final folders should be like lib/inc/excel/PHPExcel.php and lib/inc/excel/PHPExcel directory)
https://gist.github.com/gridphp/71f6e504682a2283362f5f347ecdae4c

Darwins answered 9 years ago

Hello , I gained with you the license " Developer " when performing a query, use the "Order By" instruction and gives me an error when exported to an Excel file .

"Couldn't execute query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY 1 asc' at line 1 – SELECT Opportunity, Stage, Status, B.name, B.Lastname, Customer_ID, Company_name, Origin, Destination, DATEDIFF('2016-03-30 12:14:58',Date) AS Days_to_Close, Date, Updated, SUM(Amount) AS Amount, SUM(Profit) AS Profit FROM pipeline A LEFT JOIN gwm.user B ON A.Sales_Responsible=B.Username WHERE 1=1 GROUP BY A.Opportunity HAVING ORDER BY 1 asc"

Francine answered 9 years ago

OK thank you. I will look into phpexcel.

Your Answer

14 + 20 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?