This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

craw
craw

In Build 184 (2015-01-31) they added: Lists now support exporting to CSV format via the default export controller action. Does anybody has en example how to use this?

I have a function onExport in my Controller, but I don't know how I to get the export.csv as download: public function onExport(){ $this->export(); }

Last updated

omdreamreg6295
craw
craw

Yes, it's quite simple. Controller:

public function export(){
    return $this->listExportCsv(array('filename' => 'my.csv'));
}

For Download: site.lu/backend/acme/pluginName/controller/export

omdreamreg6295
phplee
phplee

Hi Guys,

Can you explain this a bit more for me. i want a simple export button at the top of my list similar to a delete button. that when records are checked its enable and once clicked export the selected rows.

Could you please help me on this.

thanks

Vojta Svoboda
Vojta Svoboda

listExportCsv() only takes data goes to listing and sends it to the CSV exporter. So the easiest way will be to implement some kind of filtering and then export filtrated dataset to CSV.

For more check http://octobercms.com/docs/backend/lists#list-filters

phplee
phplee

thanks.

Im now using the import/export feature and to export a cvs using exportData($columns, $sessionKey = null) etc.

However when it exports I'm left with data.cv.html (why the html extention?) And also if i try an open the file i get a warning saying excel has detected its a SYLK file and may be corrupt.

Any ideas. or has anyone successfully exported a list as a CSV using: https://octobercms.com/docs/backend/import-export

thanks

jprevot
Vojta Svoboda
Vojta Svoboda

Just rename first column ID to Id, it's Microsoft error, when first two char of CSV are uppercase :-(

jprevot
jprevot

listExportCsv give error Call to undefined method MyMODEL::listExportCsv()

mano
mano

so in the output csv i get an error ￯ᄏ﾿Id Name TypeConfirmed? Createdby Added On updated On

mano
mano

Vojta Svoboda said:

Just rename first column ID to Id, it's Microsoft error, when first two char of CSV are uppercase :-(

￯ᄏ﾿Id   Username    Name    Surname Email   Registered

1 manju@gmail.com manju manju@gmail.com 2015-11-30 23:34:34

i get the above error in csv where extra chracter gets appended in the id column name and the first column which was supposed to be the id is empty

can you please tell the reason behind it

Vojta Svoboda
Vojta Svoboda

Try to rename this column to something different, maybe "Number". Otherwise I would create own export controller and own export model by http://octobercms.com/docs/backend/lists#list-filters

hardik_satasiya
hardik_satasiya

here is also one with an example, for user who need some help using examples ref: integrate-import-export-csv-backend-list-octobercms

Last updated

1-14 of 14

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.