Coder Social home page Coder Social logo

[feat]: export to csv about shadcn-table HOT 6 OPEN

Balance8 avatar Balance8 commented on May 20, 2024
[feat]: export to csv

from shadcn-table.

Comments (6)

john093e avatar john093e commented on May 20, 2024 1

Hello @yasseralsaidi, I will try to help on the direction to take for your request :)

Yes, it is possible to accomplish this task, but not using the CSV export feature from @sadmann7.

Why? This would involve considering many different factors. For example, imagine you have a million rows with thousands of columns and many text fields; this would result in a very large file.

1. Long-running Task:
In my opinion, this should be handled as a background job. I would use Inngest for such a task. A background job is necessary because Vercel only runs for a limited amount of time, depending on your account plan and runtime setup.
Capture-2024-04-21-184448

2. File Size and Memory:
Generating a CSV file as a background task requires careful memory management. Although a CSV file is typically light, it can quickly become cumbersome depending on the volume of data to be exported. For this, I would stream the data to a file saved on Uploadthing.
Capture-2024-04-21-184745

3. Task Concurrency:
Depending on your setup (runtime, etc.), be aware that generating a file takes time and can slow down other users' requests. Again, Inngest would be key to addressing this issue.

Final Workflow:

  1. A user on your platform requests an export.
  2. You save the export request with filters and other data in your database.
  3. You start an Inngest flow to generate the file (Papaparse can help to generate the file).
  4. Inngest streams the data in chunks to Uploadthing to ensure data is not lost and memory limits are not exceeded.
  5. Once the full data set is sent to your file on Uploadthing, you send a notification through your platform or by email to the user with a link to the file located on Uploadthing.

Exporting data to CSV can be quite complex!

from shadcn-table.

manaskshatriya avatar manaskshatriya commented on May 20, 2024

Any Update on the feature?

from shadcn-table.

sadmann7 avatar sadmann7 commented on May 20, 2024

i will try to put together a demo of it in the weekend

from shadcn-table.

manaskshatriya avatar manaskshatriya commented on May 20, 2024

Hey any update?

from shadcn-table.

sadmann7 avatar sadmann7 commented on May 20, 2024

Thanks for suggesting the feature.

Wrote a function to export as csv.

     <Button
        variant="outline"
        size="sm"
        onClick={() =>
          exportTableToCSV(table, {
            filename: "tasks",
            excludeColumns: ["select", "actions"],
          })
        }
      >
        <DownloadIcon className="mr-2 size-4" aria-hidden="true" />
       Export
   </Button>

from shadcn-table.

yasseralsaidi avatar yasseralsaidi commented on May 20, 2024

can we export all filterd data without to do page by page?

from shadcn-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.