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

fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
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

Other popular topics Top

stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement