I have write a code to create a Excel sheet where i’m printing some calculated table values. It is working fine. This file will be stored in the current system specified folder - this is also done by coding.
my questions are listed below
- how to save the file as write protected (as a read only file)
- how to give the background color for headings (coloring the cells)
If anyone knows about this, Please help me to resolve the issue.
anybody worked onthis? pls help to resolve the issue. How to save and open the excel sheet in readonly mode
Do you use this method to save your worksheet: sysExcelWorkbook.saveAs() ? If so, have you tried setting the fourth parameter (_readOnlyRecommended) to TRUE? I wonder if that could do the job.
Otherwise , straight after the saving your worksheet, you could call WinApi::setFileAttributes() method and set the attribute of the newly created file to read-only.
Thanks Janis. I tried saveas option but again it is asking for a confirmation. I believe WinApi is fine. Now the file saved as Readonly.
I want to open the same file thro code. Is it possible. If you know, pls help
Winapi is your friend once again: winapi::shellExecute(“C:\YOUR_FILE.xls”)
yes. below is the code.
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbooks.open(filename); //give the file name which you want to open