apoorv-2204

apoorv-2204

How to write data to xlsx with all of its glory of piivot tables, colors, formulas?

Goal: I need to export reports as part of CRM as xlsx, as with all the format provided

Required Formatting:

  • pivot tables
  • filters, sort
  • cell formatting (color, bg color,border,etc)
  • formulas
  • multiple sheets
  • font formatting

Question:
Q1. Is it possible to export all this data to xlsx with feature mentioned above ?

  • it means i want to query data from db and write to excel with formatting and send for download
    Q2
  • which libraary should I usee for it?

List of Libraries I found, I have gone through them but not sure
link
https://hex.pm/packages/xlsxir

Most Liked

MRdotB

MRdotB

I’ve extensively used the Elixlsx package to generate complex Excel exports for a cashier app, covering various aspects like VAT, sales, discounts, and more (10 sheets export). While the library is functional, it has some limitations, such as lacking support for pivot tables, filters, and sorting. Additionally, the performance of the library is not great.

Looking back, I wish someone had shared a more efficient method for creating complex Excel exports before I began this project. Here’s an approach that could save you significant time and effort:

  • Start by working closely with the accountant or the person who requires the export.
  • Create a Manual Excel Template: Instead of programmatically generating the entire Excel sheet, manually create a template in Excel that includes all necessary calculations using pivot tables. The template should have one or more sheets dedicated to raw data.
  • Programmatically Feed Raw Data into the Template: Use your database to populate the raw data sheets within the template. The pre-built formulas and pivot tables in the template will automatically handle all calculations and formatting.

If there’s ever an issue with the calculations, it’s easier to debug. Either it’s a problem with the raw data or an issue with the Excel template’s formula.

The primary downside of this approach is the presence of an extra sheet dedicated to raw data. However, I would choose this method 100% if I had to redo any complex Excel export in the future.

10
Post #2
shishini

shishini

You can waste a lifetime editing HTML by hand
– Anonymous

I know and worked on two types of Excel reports (there could be more I dont know)

1. Data Tab
The excel document have (usually a hidden) tab, that have the data
and other tabs act as reports on this data, usually pivot tables, the data table may include calculated columns, but make sure you know the difference between measure and calculated column

2. External Data source
I add a connection to an external data source , and create sheets or pivot tables that use this source

In both types, you create the Excel report using Excel and you only automate updating the data source, whether external in a database or the data tab inside the excel document

So basically you are creating an ETL job, that is it

The need to dynamically create the report, suggest you are creating an excel report writer in Elixir, so this is a completely different thing

Reporting writer vs Report

Don’t create a report writer, when all you want is a report
(Editing HTML by hand is an example of solving the wrong problem)

Where Next?

Popular in Questions Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
kostonstyle
Hi all I want to have a unix time, from the current time plus 1 hour. DateTime.now + 1 hour How to get it in elixir? Thanks
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New

Other popular topics Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement