How to create and write data in .xlsx file into the SD card using any microcontrollers like stm32,
Does anyone know how to create and write data in .xlsx file into the SD card using any microcontrollers like stm32, esp32?
Solution:Jump to solution
I apologize for the confusion. You are right, the FatFs library does not support the Excel file format directly. You will need to use a separate library for Excel file manipulation.
One popular library for Excel file manipulation is the OpenXML SDK. You can find more information and examples on how to create an Excel workbook using OpenXML in the official documentation: https://docs.microsoft.com/en-us/office/open-xml/how-to-create-a-spreadsheet-document-by-providing-a-file-name
Another option is to use the ExcelDataReader/ExcelWriter library, which allows you to read and write Excel binary format (.xls) files. You can find more information and examples on how to use ExcelDataReader/ExcelWriter on the official GitHub repository: https://github.com/ExcelDataReader/ExcelDataReader...
GitHub
GitHub - ExcelDataReader/ExcelDataReader: Lightweight and fast libr...
Lightweight and fast library written in C# for reading Microsoft Excel files - ExcelDataReader/ExcelDataReader
10 Replies
I'm trying to write different frequencies of data into excel workbook in SD card using STM32 uC. I want to write different frequencies of data in different sheets in a same excel workbook.
I want to do this using STM32, how can I do that?
Step 1: Set up the necessary hardware and connections.
- Connect the SD card module to the appropriate SPI (Serial Peripheral Interface) pins on your STM32 microcontroller.
- Ensure that you have the necessary hardware support for SD card communication, such as an SD card slot or an SD card breakout board.
Step 2: Install the required libraries and drivers.
- For the STM32 microcontroller, you can use the STM32Cube software suite provided by STMicroelectronics, which includes a library called "FatFs" for SD card communication.
- Additionally, you'll need to download and install the appropriate library for Excel file manipulation.
Step 3: Initialize the SD card and establish communication.
- Use the FatFs library to initialize the SD card and establish communication with the microcontroller.
- Refer to the FatFs library documentation and examples for detailed instructions on how to initialize the SD card and mount the file system.
Step 4: Create a new Excel workbook file on the SD card.
- Use the Excel file manipulation library to create a new Excel workbook file in memory.
- Some popular libraries for Excel manipulation are OpenXML (for creating Office Open XML-based files) and ExcelDataReader/ExcelWriter (for writing to Excel binary format).
- Follow the documentation and examples provided by the library you choose to create a new workbook file and set up the necessary data structure.
Step 5: Write the data for each frequency to a different sheet in the Excel workbook.
- Use the same Excel file manipulation library to generate the XML code for each sheet and append it to the Excel file.
- Create a new sheet for each frequency and populate it with the corresponding data.
- Repeat this process for each frequency you want to write.
Step 6: Close the Excel workbook file on the SD card and release resources.
- Use the appropriate functions from the Excel file manipulation library to close the workbook file and release any allocated resources.
- Ensure that all data has been properly saved and closed before proceeding.
Required Libraries:
- STM32Cube software suite (FatFs library): To manage the communication with the SD card.
- OpenXML SDK or ExcelDataReader/ExcelWriter: Choose one of these libraries for Excel file manipulation.
-
I already tried this. FATFS library is not supporting excel file format (.xlsx)
If possible, can you please provide any resource link or example?
Solution
I apologize for the confusion. You are right, the FatFs library does not support the Excel file format directly. You will need to use a separate library for Excel file manipulation.
One popular library for Excel file manipulation is the OpenXML SDK. You can find more information and examples on how to create an Excel workbook using OpenXML in the official documentation: https://docs.microsoft.com/en-us/office/open-xml/how-to-create-a-spreadsheet-document-by-providing-a-file-name
Another option is to use the ExcelDataReader/ExcelWriter library, which allows you to read and write Excel binary format (.xls) files. You can find more information and examples on how to use ExcelDataReader/ExcelWriter on the official GitHub repository: https://github.com/ExcelDataReader/ExcelDataReader
Please note that both options mentioned above require you to manually generate the XML code for the Excel file structure. This can be a complex task, so I recommend thoroughly reading the documentation and examples provided with each library to understand the process and adapt it to your specific requirements.
I hope this helps! Let me know if you have any further questions.
GitHub
GitHub - ExcelDataReader/ExcelDataReader: Lightweight and fast libr...
Lightweight and fast library written in C# for reading Microsoft Excel files - ExcelDataReader/ExcelDataReader
Thank you so much man!
I'll try this, then tell my feedback to you 🙂
I recommend using .csv it is easy and you can deal with it as it is a txt file
Yes, I know very well. I'm doing some experiments. So that I want to use .xlsx format
Can you provide a roadmap for embedded system