Now you can generate Excel and Word File with NO extra charge, using Jakarta POI
- .NET Framework 2.0
- JSharp framework 2.0
- Configure your model to compile and execute with Framework 2.0
- DLL from Jakarta poi
Install JSharp (vjredist)
Install the DLL from Jakarta in your model (jakartapoi-winfx-dll-251-3), if you are compiling for WEB, put them on “DATAxxx/web/bin/”
Now you are ready to Read or Create Excel or Word files, here an example:
&excel is ExcelDocument Type
Place the “UseAutomation” = 0 before the “Open” command line.
Event "Excel" &excel.UseAutomation = 0 &excel.Open(&File) If &excel.ErrCode <> 0 msg(&excel.ErrDescription) else &excel.Clear() &excel.Cells(1,1).Text = 'Customers list' &excel.Cells(1,1).Bold = 1 &excel.Cells(1,1).Color = 54 &excel.Cells(1,1).Size = 10 &excel.Cells(3,1).Text = 'Customer Id' &excel.Cells(3,1).Italic = 1 &excel.Cells(3,1).Bold = 1 &row = 4 &col = 1 For each line in Grid &excel.Cells(&row,&col).Number = CustomerId &excel.Cells(&row,&col).Color = 3 &row = 1 endfor &excel.Save() endif EndEvent
To implement the uploading of blob fields on the web, temporary directories are used to save the file to the server’s disk first and then upload it to the database
The directories are specified using the Blob Local Storage Path and Temp Media Directory model properties. To have the files automatically deleted, in Upgrade 3 you can create a global.asax file and save it to the application directory.
The file must contain the following code:
<%@ Import namespace=”System.IO” %>
<Script language=”C#” runat=”server”>
public void Application_OnStart()
Application[“TemporaryFilesToDelete”]= new ArrayList();
public void Application_OnEnd()
ArrayList toDelete = (ArrayList)(Application[“TemporaryFilesToDelete”]);
foreach( string fileName in toDelete)
This way the files will be deleted when the application’s memory usage exceeds the configured maximum or according to the recycling configuration. That is to say, when the process (Aspnet_wp or W3wp) is recycled, it deletes all the files that have been created since the application was started (and that haven’t been deleted after ending a session).
WARNING: This implementation has a high startup cost, which is an obstacle for prototyping. It implies that the person who executes the first request after restarting the process serving the web objects (w3wp or aspnet_wp) must run this deletion and therefore delay the request.