question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create file in memory

See original GitHub issue

I want to create a report using an ExcelHelper class with ClosedXML. Now I save it in the TEMP folder, then open it via Process.Start(path). Yes, it is not the ideal solution but a workaround. I’d like to save it on a filestream (which I can), then execute Excel using the fs (which I cannot). I don’t want to use Interop.Excel, because that’s why I use ClosedXML.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
vbjaycommented, Jan 26, 2017

The other thing you can do is watch for the process to quit. https://msdn.microsoft.com/en-us/library/fb4aw7b8(v=vs.110).aspx

On Wed, Jan 25, 2017, 5:20 PM Jay Asbury vbjay.net@gmail.com wrote:

That is a dumb way to do that. You have a loop that is processing and creating an exception each time.

Your process should be

List<string> cleanup = new…

When you create excel report

Cleanup.add(path to excel file)

When you close window.

List<string> tmp = new… foreach (string f in cleanup) { Try { //Delete file // Add f to tmp

} Catch…{}

Cleanup=cleanup.except(tmp)

On Wed, Jan 25, 2017, 12:28 PM the f. notifications@github.com wrote:

I created a random-named Excel file with each action and open it using ‘Process.Start(path)’. Immediately after that, I created a while(!success) loop with a try - catch. In try I wrote File.Delete(path) and catch the IOException. So that when the user closed the Excel window, it deletes the file from temp. This is not the best way because it needs file write, read and delete actions, which requires so many system calls. This is the bottleneck of the process. That’s why I want to send the filestream into Excel through ClosedXML.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ClosedXML/ClosedXML/issues/167#issuecomment-275174264, or mute the thread https://github.com/notifications/unsubscribe-auth/ADdhsSkvUjQAiVaqZbLVUPEebonlp20Sks5rV4YkgaJpZM4Lsl3J .

0reactions
vbjaycommented, Jan 26, 2017

That too. I was more focused on the fact he was looping through and waiting for a non exception to quit the loop.

On Thu, Jan 26, 2017, 11:09 AM Francois Botha notifications@github.com wrote:

There’s nothing wrong with using Interop to check whether the file is currently open in Excel.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ClosedXML/ClosedXML/issues/167#issuecomment-275429331, or mute the thread https://github.com/notifications/unsubscribe-auth/ADdhsU-Bg8AIHCH4f3pvy4Vj5_87a-_wks5rWMUigaJpZM4Lsl3J .

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create a new java.io.File in memory? [duplicate]
It is not possible to create a java.io.File that holds its content in (Java heap) memory *. Instead, normally you would use a...
Read more >
How to make a temporary file in RAM?
We can then use the mktemp command with the --tmpdir option to create temp files and directories in this tempfilesystem thus creating tempfiles ......
Read more >
Memory-Mapped Files
To work with a memory-mapped file, you must create a view of the entire memory-mapped file or a part of it. You can...
Read more >
Example: an in-memory file system
The file system itself will be extremely simple. A file system object will just be a hash table that maps file names to...
Read more >
Java In Memory File: Java Explained
Java In Memory File (IMF) is an important concept in Java. IMFs are temporary storage areas used to store data while a program...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found