Export BizFormItems in to CSV

Luke Hook asked on May 24, 2018 14:07

Hi there,

Apologies for my ignorance with this. I'm simply looking to export all forms and save as CSV files on the file system. How can I do this in C#. I can get the form data out using:

ObjectQuery<BizFormItem> data = BizFormItemProvider.GetItems(formClassName)

But not sure how to translate that 'data' in to CSV. I don't really want to make a custom model for each form just export them down. The idea being this would then run as a scheduled task in Kentico.

Thanks

Correct Answer

Brenden Kehren answered on May 24, 2018 15:01

You should be able to use this:

ObjectQuery<BizFormItem> data = BizFormItemProvider.GetItems("formClassName");
if (!DataHelper.DataSourceIsEmpty(data))
{
    DataExportHelper eh = new DataExportHelper(data.Result);
    eh.ExportData(DataExportFormatEnum.CSV, Page.Response);
}
1 votesVote for this answer Unmark Correct answer

Recent Answers


Luke Hook answered on May 24, 2018 15:42

That's perfect (feel pretty stupid not to have found that) thanks so much for your help

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.