i use below aspose libraries in spring boot application.
Below url is used for downloading files from grid cache.
i dont face any issue when i open the download files with xlsx extension.
i use Microsoft excel application to open the download files in windows operating system.
when i open the download files which has extensions(XLSM, XLSB, XLTM, XLTX) , it shows below error message
image.png (33.8 KB)
when i open the downloaded excel file which has xls extension, i receive below popup, but iam able to click “yes” and view the file.
image.png (32.9 KB)
Http url
http://localhost:8080/GridJs2/GetFile?id=1-10
Http Method
GET
Java aspose libraries
com.aspose:aspose-cells:25.7
com.aspose:aspose-cells:25.7:gridjs
i checked the code.
image.png (26.3 KB)
Above code from aspose-cell library gets invoked when /GetFile api is triggered.
this logic looks for a file within streamcache
and downloads the matching file. The matched file doesnot have any file extension in it. this seem to be a problem for this api.
image.png (7.7 KB)
Could you let us know how to fix this issue?
We are using below api to allow end-users to download the file to their system. Should we use this api for this usecase? does aspose-cell support this usecase? or should we create a new endpoint for this usecase?
http://localhost:8080/GridJs2/GetFile?id=1-10
please advice.
@divine1
It appears that you are experiencing issues with opening files in XLSM, XLSB, XLTM, and XLTX formats, which may be related to how these files are being handled in your application. Since you mentioned that the downloaded files do not have any file extensions, this can lead to problems when attempting to open them in Microsoft Excel.
To resolve this issue, please ensure that the files are saved with the correct extensions during the download process. Here are some steps you can take:
-
Check File Naming: When serving the file for download, ensure that the file name includes the appropriate extension. For example, if you are downloading an XLSM file, the file name should end with .xlsm
.
-
Modify the API Response: In your /GetFile
API, make sure that the response headers include the correct Content-Disposition
header to specify the filename. For example:
response.setHeader("Content-Disposition", "attachment; filename=\"yourfile.xlsm\"");
-
Verify File Content: Ensure that the content being served is indeed a valid XLSM, XLSB, XLTM, or XLTX file. You can verify the file format before sending it to the client.
-
Testing: After implementing these changes, test the download functionality again to confirm that the files open correctly in Excel.
If you continue to encounter issues, consider creating a dedicated endpoint for handling these specific file types, ensuring that the logic for serving files is tailored to the requirements of each format.
If you need further assistance, please provide additional details about how the files are being generated and served in your application.
i have done all these changes, it doesnot work due to the logic used by aspose-cell library to download the file.
it looks like i shouldn’t be using aspose-cell api for download a file to end-user machine. a dedicated custom api needs to be implemented. please advice
@divine1
can you provide a sample project to show this issue.
actually ,the cache file in GridJs is always saved in .xlsx format.
please try our java demo here.
when user want to save to any other format,we will trigger an internal convert .so that
.xlsx will convert to any kinds of format files like pdf ,xls,xlsb,html ,etc.
i want to download in the same original format. iam using below api for it. i had explained how the logic in aspose-cell library works in my above posts
http://localhost:8080/GridJs2/GetFile?id=1-10
attached the input files which i used.
additionalFileFormats.7z (45.6 KB)
the aspose cell code flow target’s below files for /GetFile api
image.png (7.7 KB)
@divine1
Please follow the github demo.
First when you open a file, we will generate a uniqueid for the file. Then you can see the url is like this:
QQ截图20251001232145.png (44.6 KB)
http://localhost:8080/gridjsdemo/Uidtml?filename=ActionItems_Status.xlsb&uid=c2620793-083e-443e-9591-3d63be57a787.xlsx
after ui changes, for example, update a cell, the file will be saved in streamcache path with the uid name:
c2620793-083e-443e-9591-3d63be57a787.xlsx
when clicking file download, we will do an internal file format convert from .xlsx to the target formated file, the code is in
https://github.com/aspose-cells/Aspose.Cells.Grid-for-Java/blob/main/Examples.GridJs/src/main/java/com/aspose/gridjs/demo/controller/GridJs2Controller.java
@PostMapping("/Download")
public ResponseEntity<String> download(HttpServletRequest request) {
return super.download(request);
}
For example when choose download original format, we will convert the c2620793-083e-443e-9591-3d63be57a787.xlsx to ActionItems_Status.xlsb.
This is the basic process. After I select save original and then I select save to xlsx in the streamcache path, we can see:
it generates the extra two files:
c2620793-083e-443e-9591-3d63be57a787.xlsx.ActionItems_Status.xlsb =>when I select save orginal
and
c2620793-083e-443e-9591-3d63be57a787.xlsx.ActionItems_Status.xlsx =>when I select save xlsx
those are the final files get in client side when user clicks download menu. And, they can open successfully in MS-Excel without raising any warning alert.
The related document is here:
Actually, we have encapsulated the common complex logic inside the dowload API.