How to get rid of the "Access to the path 'c:\Example.xlsx' is denied."

How to get rid of the "Access to the path 'c:\Example.xlsx' is denied."

  

Hi, 

I've tried to use "Excel_Package_New" component to write the customize formatted values in excel file. This works good when I deployed the application to the servers which I have in my infrastructure. When I tried the same solution in Outystem cloud, I always gets "Access to the path 'c:\Example.xlsx' is denied." error while exporting the records in excel file where I am writing the values in customize format.

Any help would be much appreciated.


Thanks

You don't have permision to Save it the "C:\"; but you have full access on the webserver; you could save it to 

GetOwnerURLPath() + "/Example.xlsx"

Hope this helps.

Kind regards,

Matthias

Matthias Preuter wrote:

You don't have permision to Save it the "C:\"; but you have full access on the webserver; you could save it to 

GetOwnerURLPath() + "/Example.xlsx"

Hope this helps.

Kind regards,

Matthias

Hello Matthias,

Before putting my problem to forum, I've tried for this as well which you suggested.

Thanks,

Pradeep.


Hi Pradeep,

What error did you get when using GetOwnerURLPath()?

And? This did work right?

Matthias Preuter wrote:

And? This did work right?


It did not work

Kilian Hekhuis wrote:

Hi Pradeep,

What error did you get when using GetOwnerURLPath()?

I got this error "Could not find a part of the path 'c:\Bookings_Interface\Example.xlsx'."


Hi Pradeep,

GetOwnerURLPath() never returns a Windows path, so it's impossible that GetOwnerURLPath() gives you the "c:\Bookings_Interface". I'm not sure what you did, but not what you claim you did.

Kilian Hekhuis wrote:

Hi Pradeep,

GetOwnerURLPath() never returns a Windows path, so it's impossible that GetOwnerURLPath() gives you the "c:\Bookings_Interface". I'm not sure what you did, but not what you claim you did.


Let me send you the OML which I'm using.

Pradeep Dubey wrote:

Kilian Hekhuis wrote:

Hi Pradeep,

GetOwnerURLPath() never returns a Windows path, so it's impossible that GetOwnerURLPath() gives you the "c:\Bookings_Interface". I'm not sure what you did, but not what you claim you did.


Let me send you the OML which I'm using.

Killan,

Please see attached OML files and dependencies. Also attached the screenshot

Thanks,

Pradeep.


Hi Pradeep,

I'm seeing a few weird things there:

  1. You have added the GetOwnerURLPath() to a Download Statement. However, the Download Statement will pop-up a File Save dialog from your browser, and the File Name Input Parameter specifies the default file name the pop-up will show. There's no way to specify a specific location.
  2. You use File_WriteText, combined with a BinaryDataToText(). However, not all binary data can be represented as text, which means that you will likely get a corrupted version of your Excel file.
  3. Why do you want to write your file to a location on the server, when you are also trying to download it?
  4. When opening the Excel file, where is it intially coming from? Workbook_Open very likely needs an existing workbook?
  5. You are using GetOwnerURLPath(), but that will only return a URL, not a file path. You need Path_GetApplicationDirectory() from the FileSystem Extension instead.

Kilian Hekhuis wrote:

Hi Pradeep,

I'm seeing a few weird things there:

  1. You have added the GetOwnerURLPath() to a Download Statement. However, the Download Statement will pop-up a File Save dialog from your browser, and the File Name Input Parameter specifies the default file name the pop-up will show. There's no way to specify a specific location.
  2. You use File_WriteText, combined with a BinaryDataToText(). However, not all binary data can be represented as text, which means that you will likely get a corrupted version of your Excel file.
  3. Why do you want to write your file to a location on the server, when you are also trying to download it?
  4. When opening the Excel file, where is it intially coming from? Workbook_Open very likely needs an existing workbook?
  5. You are using GetOwnerURLPath(), but that will only return a URL, not a file path. You need Path_GetApplicationDirectory() from the FileSystem Extension instead.


Killan,


I wrote this to download the booking records in the formatted excel. Since I dont have access to cloud server where I can put excel file to use it. My question, how we can write well formatted excel when working on cloud. As this is working good to inhouse environment. Can you suggest some example

Solution

Hi Pradeep,

If you have a default Excel to use as template, add it as a Resource:

  1. Click the Data tab in Service Studio;
  2. Right click the Resources Folder (the very last one), and selet "Import Resource";
  3. Select the Excel file to use as template and click "ok";
  4. Set the Resource's "Deploy Action" Property to "Deploy to Target Directory", and set the "Target Directory" to the right sub folder, e.g. "bin".

combined wit Path_GetApplicationDirectory (the one I mentioned my the previous post) you can then read that file.

If the template is dynamic, you need to go for a different solution, e.g. store it in the database in a dedicated Entity, an retrieve it when needed. You need to have a Workbook_Open Action in that case that execpts the Binary Data as input, rather than a file path (which would be a good idea anyway).

Solution

Kilian Hekhuis wrote:

Hi Pradeep,

If you have a default Excel to use as template, add it as a Resource:

  1. Click the Data tab in Service Studio;
  2. Right click the Resources Folder (the very last one), and selet "Import Resource";
  3. Select the Excel file to use as template and click "ok";
  4. Set the Resource's "Deploy Action" Property to "Deploy to Target Directory", and set the "Target Directory" to the right sub folder, e.g. "bin".

combined wit Path_GetApplicationDirectory (the one I mentioned my the previous post) you can then read that file.

If the template is dynamic, you need to go for a different solution, e.g. store it in the database in a dedicated Entity, an retrieve it when needed. You need to have a Workbook_Open Action in that case that execpts the Binary Data as input, rather than a file path (which would be a good idea anyway).

Thanks Killan, It's worked


You're welcome. Happy coding!