How do I properly clean up Excel interop objects?

I’m using the Excel interop in C# (ApplicationClass) and have placed the following code in my finally clause: while (System.Runtime.InteropServices.Marshal.ReleaseComObject(excelSheet) != 0) { } excelSheet = null; GC.Collect(); GC.WaitForPendingFinalizers(); Although this kind of works, the Excel.exe process is still in the background even after I close Excel. It is only released once my application is … Read more

What is a correct MIME type for .docx, .pptx, etc.?

For older *.doc documents, this was enough: header(“Content-Type: application/msword”); What MIME type should I use for new .docx documents? Also, for pptx and xlsx documents? 9 Here are the correct Microsoft Office MIME types for HTTP content streaming: Extension MIME Type .doc application/msword .dot application/msword .docx application/vnd.openxmlformats-officedocument.wordprocessingml.document .dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template .docm application/vnd.ms-word.document.macroEnabled.12 .dotm application/vnd.ms-word.template.macroEnabled.12 .xls application/vnd.ms-excel … Read more

Syntax error on token(s), misplaced construct(s)

You need to place all statements after the declarations in a code block, e.g. method rather than the class block. Logically it probably makes sense to place all statements in the code block but the non-declarative statements need to be enclosed within the new block private void processFile() { data.put(“1”, new Object[]{“ID”,”NAME”, “LASTNAME”}); // <–Syntax … Read more