How can I add an Excel button to export the “État du stock” in Dolibarr?

Question: How can I add an Excel button to export the “État du stock” in Dolibarr?

Hi everyone :waving_hand:

I’m customizing Dolibarr and I would like to add a new button named “Excel” on the Product Stock Card page:

http://localhost:70/backuporo/product/stock/card.php?id=3&save_lastsearch_values=1

When I click this “Excel” button, I want Dolibarr to generate and download an Excel file containing the current stock report (État du stock) — for example, the list of warehouses, available quantities, movements, etc.

I would like to know:

  • :brain: Which file(s) should I modify to add this button?
  • :gear: What is the best way to export the data? (use PhpSpreadsheet, existing Dolibarr helper, or a built-in export function?)
  • :light_bulb: Is there maybe already a function or module that allows stock export in Excel?

From what I found, the page I need to edit seems to be:

/htdocs/product/stock/card.php

If anyone has an example or snippet for adding an action=exportexcel or dolGetButtonTitle() button that generates an Excel export, it would be super helpful :folded_hands:

Thanks in advance for your help!

Hi,
I recommend you don’t modify the Dolibarr source code; you’ll lose your work when you install the next update.
Create a custom module instead, starting from here.
Alternatively, try looking on Dolistore, you’re sure to find something that’s right for you.

@Yassine why don’t you just use the existing export function?

/exports/export.php?leftmenu=export

top menu tools, left menu export

This is a feature included in the Dolitools module from Altairis company :wink:
(button to export any dolibarr list to excel)