I'm trying to export a data view to Excel format but can't find a helper that works with Cake 2.x
The closest I found was http://bakery.cakephp.org/articles/wasenbr/2007/04/12/excel-xls-helper but that throws errors like this
call_user_func_array() expects parameter 1 to be a valid callback, class 'XlsHelper' does not have a method 'beforeRender'
Does anybody have a link to a helper that will work in newer versions of Cake?
The helper works if you just add blank functions for all the errors that appear.
Related
HI I'm able to smart import Projects in ODI using SDK. but i'm unable to use the predefined method which sets actions like merge, create copy, ignore, reuse, while importing the projects.
Please help me to implement the below method,
setMatchedFCODefaultImportAction(java.lang.String pFCOObjType, int pSmartImportAction)
by using below method i'm directly importing projects.
importObjectsFromXml (fnameAndPath, ExportKey, ExportWithoutCipherData);
I want to implement above mentioned actions, please help me.
thanks
Unfortunately you can not use setMatchedFCODefaultImportAction to specify the action for a specific object like a project as in your code :
smartImpServ.setMatchedFCODefaultImportAction("Dev_ODI_Project", 1);
It can only define the default action for a First Class Object i.e. for all the objects of a specific type. For instance you can set the default actions for any project as CREATE/COPY (equivalent to 1 as you used in your code):
smartImpServ.setMatchedFCODefaultImportAction(ISmartImportService.PROJECT_OBJECT_NAME, ISmartImportService.SMART_IMPORT_ACTION_CREATE_COPY);
The values you can use as the pFCOObjType parameters are all the Fields ending by _OBJECT_NAME in the ISmartImportService interface.
If you want to specify the action for a specific object, you would need to use a response file from a previous import with the importFromXml method.
As you can see that it's not recognising the class MySqlConnection. Thus not allowing me to create its object. The class and package name is correct and its still not working. Is there something I am missing?
Typo... Try to change from MySqConnection to MySqlConnection.
I would like to implement an autoslug-function for two models in CakePHP3 and use the beforeSave-callback for that which works fine. However the slug structure is a bit different than in Inflector::slug, so I wrote a small function for the different structure which finally leads to my question
In Cake2 I would have placed this helper function in AppModel which is not existing anymore. What's the best way to do that now? A behaviour (which seems a bit biggish for 2 lines of code) or class AppTable extends Table or ..?
Make it a behavior and use it where needed instead of putting it in a super model class. If you put that into a plugin and repository you can simply add your plugin as package via composer for every app that needs this plugin.
I'm using cakephp XLS helper to generate Excel report in my project.
But the generated file is giving warning message in windows system as below.
Similarly the same file displays the entire xml mark-up in open-office on linux as below.
Part of the view file code is as below.
$xls->setHeader('Report_'.date('Y_m_d'));
$xls->addXmlHeader();
$xls->setWorkSheetName('Enrollment Report');
//1st row for columns name
$xls->openRow();
$xls->writeString('ID');
$xls->writeString('Zipcode');
My Client wants a proper excel report with-out any warnings in windows.
Please suggest me any excel helper for cakephp which will generate proper excel file on all the platform and different application.
Your problem is that you are using a helper that puts your data in xml format. Excel can read XML and HTML but with a warning. You should use the one that Ivo suggested in the comments. LINK
This helper really makes an xls valid format, that complys with open office and office. Also, this helper relies on PHPExcel class that is constantly updated here so your code will be easy to upgrade if needed.
Remember to follow instructions given in the helper page.
I've tried a lot of this xls helper for cakephp, but neither one work as expected, either outdated or create xml o html tables or didn't work at all, haven't tried this one though... still creating a helper using PHPExcel shouldn't give you much trouble, you may use this tutorial as a how to base to modify the helper.
I think you need to set the mime-type. This has happened to me in the past and it was when the mime-type of an older excel helper was set to an out-dated value.
The code from the linked (by Ivo) helper has the following:
function _output($title) {
header("Content-type: application/vnd.ms-excel");
header('Content-Disposition: attachment;filename="'.$title.'.xls"');
header('Cache-Control: max-age=0');
$objWriter = new PHPExcel_Writer_Excel5($this->xls);
$objWriter->setTempDir(TMP);
$objWriter->save('php://output');
}
I would make sure you are:
a) using the newest helper (http://bakery.cakephp.org/articles/melgior/2010/01/26/simple-excel-spreadsheet-helper)
b) that the mime-type is actually set.
c) that that specific mime-type is accurate.
In the recent cakePHP 1.3.4 version I discovered that Sanitize::html returns double encoded html entities - because of the newly added fourth parameter of htmlentities 'double_encode'.
Here is a corresponding ticket on cakePHP: http://cakephp.lighthouseapp.com/projects/42648/tickets/1152-sanitizehtml-needs-double_encode-parameter-in-htmlentities
Since I need to use cakePHP 1.3.4 on PHP 5.2.14 I need to change the double_encode parameter. Is there a way to overload the Sanitize::html method in cake so I don't have to fiddle with the core?
You can subclass it in the /app/libs directory:
App::import('Sanitize');
class MySanitize extends Sanitize {
public static function html(...) {
...
}
}
You'll have to switch to use MySanitize instead of Sanitize, but that shouldn't be a big problem. A text find/replace can take care of it if you're using it a lot already.