Author Topic: Export of detail grids  (Read 2255 times)

maui_uku

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 9
    • View Profile
Export of detail grids
« on: April 23, 2020, 10:58:21 pm »
Thank you very much, Paramvir!  That fixed it.

I have another issue with same code example with the excel export.  I have two ASP.NET controllers set up to handle the post and get just like in Demo sample code.  The excel file gets generated but with an error displayed when trying to open it

And then when it is opened it only shows the main rows and not any of the detail rows.  I have attached two pictures to demonstrate what is happening.

Here are the two controller methods:

Code: [Select]
[HttpPost, ValidateInput(false)]
        public String exportData(String pq_ext, String pq_data, bool pq_decode, String pq_filename)
        {
            String[] arr = new String[] { "csv", "htm", "json", "xlsx", "zip" };
            if (arr.Contains(pq_ext))
            {
                String filename = pq_filename + "." + pq_ext;
                Session["pq_data"] = pq_data;
                Session["pq_decode"] = pq_decode;
                Session["pq_filename"] = filename;
                return filename;
            }
            else
            {
                throw new Exception("unsupported format!");
            }
        }

        [HttpGet]
        public FileContentResult exportData(String pq_filename)
        {
            if (Session["pq_filename"].ToString() == pq_filename)
            {
                String contents = Session["pq_data"].ToString();
                byte[] bytes = ((bool)Session["pq_decode"]) ? Convert.FromBase64String(contents) :
                    new System.Text.UTF8Encoding().GetBytes(contents);
                return File(bytes, "application/octet-stream", pq_filename);
            }
            else
            {
                throw new Exception("unknown file.");
            }
        }

Thoughts?

Thank you.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6283
    • View Profile
Re: Export of detail grids
« Reply #1 on: April 24, 2020, 12:01:15 pm »
Export of detail grids doesn't take place automatically along with export of main grid.

Detail grids need to be exported separately and their worksheets combined with the workbook of main grid.

Please send over the Excel file that is generating the error.

maui_uku

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Export of detail grids
« Reply #2 on: April 24, 2020, 12:16:28 pm »
Thank you for the tip on the detail grids.  I will change it up to do that.

Attached is the excel file that has that error.

Thanks.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6283
    • View Profile
Re: Export of detail grids
« Reply #3 on: April 24, 2020, 04:30:29 pm »
There is error in Excel file because of html in the grid title "<p>Payroll Annual Control</p>".

Please either remove it in grid definition itself or you can make it plain text at the time of intermediate workbook generation step.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6283
    • View Profile
Re: Export of detail grids
« Reply #4 on: May 04, 2020, 10:21:01 pm »
Please check this new example for export of detail grids. It might be helpful for your requirements.

https://paramquery.com/pro/demos/export_detail
« Last Edit: May 04, 2020, 10:23:16 pm by paramvir »