Search code examples
asp.netexport-to-excel

Restrict opening .xls files with notepad


I need to restrict users from opening an Excel (.xls) file with notepad.

I have an application that exports data into .xls format. Now when I open the generated file with notepad I am able to see the contents clearly but if I open a normal excel file with notepad it will show the contents in "corrupted" format.

How can I make the contents of the generated xsl file appear "corrupted" when opened with notepad?

Thanks


Solution

  • I think you are not writing a (binary) Excel file, but a CSV (text) file that you give a .xls extension. Excel will open that fine, but Notepad also.

    What you need to do is write a real Excel file. I've has some success using ExcelLibrary. But also some issues: make sure the resulting file is at least 7k in size, by appending empty rows.