0

Our application exports snippets of databases in XLSX format. We wrote our own code on top of System.Packaging as it is many (many!) times faster than using the Excel objects.

Right now we save these files with a .xlsx format, and that works OK. However, it would be much nicer if double-clicking one of these opened our app instead, but failed back to Excel on machines without it.

I know that SpreadsheetML has a feature to do this. If you insert this near the top of the file:

<?mso-application progid=""Excel.Sheet""?>

some sort of magic occurs that causes Excel to open on Win machines. While this might work in SML files, it does not appear to work in "real" xlsx files - I tried adding this line to various parts of the workbook structure but it remained unrecognized.

So is there a similar mechanism we can use in "true" XLSX files generated by System.Packaging? Or some other Windows mechanism we should use in these situations?

Maury Markowitz
  • 9,082
  • 11
  • 46
  • 98
  • Could you create a windows service that monitors a user opening a file (or triggers when new instances of Excel are created), end the Excel process and create a new instance of your program? Definitely not the most glamorous approach but I can't think of anything similar to the feature suggested above offered by Excel – Aaron Yarborough Jul 19 '17 at 16:10
  • That would require the file to retain the .xlsx extension, so how would I know it came from our app? It also seems very heavyweight. Is there no general way to define a backup editor? – Maury Markowitz Jul 19 '17 at 16:13
  • 1
    Oh sorry, I realize I forgot to mention this part: my idea is to change the file extension to something associated with our app, like ".thisfile".That still works for ODF/SML files, as the internal progid redirects it to Excel. – Maury Markowitz Jul 19 '17 at 16:49
  • Ah right, I'm with you now. Hm, as far as I know I don't think there's anything that Windows offers that lets you specify a 'backup' program to use which is what I think you're looking for (correct me if I'm wrong!). The only way I can think of it so associate the file type with a batch/script file or a 'middle-man' program that can determine whether or not your app is installed. And if not, launch Excel. However, it sounds like you don't want a dependency like this. – Aaron Yarborough Jul 20 '17 at 10:41

0 Answers0