creating excel file with comments using javascript
Hi,
I want to create an excel file using on the client side using javascript.
I created the file using
this
.document.execCommand("SelectAll", false); this.document.execCommand("Copy", true); this.document.execCommand("UnSelect", false);var
oXL = new ActiveXObject("Excel.Application");document.body.style.cursor =
'default';oXL.Visible =
true;var
oWB = oXL.Workbooks.Add();var
oSheet = oWB.ActiveSheet; oSheet.Paste();oXL.Visible =
true;oXL.UserControl =
true;I am working with html and javascript.
I created a table in html and copied the content of the table to the excel file .
But I want to add comments in some cells.
I don't know hoe to add the comments in the eacel file using javascript.
please help.
Thanks
Vinod
Answers
Hi vinod,
If you would like to add comments to in some cells of an Excel file using javascript, you can try this code line - "oSheet. Cells(1, 1).AddComment("Test comment.");". The whole javascript sample codes as follows:
Code Blockthis.document.execCommand("SelectAll", false);
this.document.execCommand("Copy", true);
this.document.execCommand("UnSelect", false);
var
oXL = new ActiveXObject("Excel.Application");document.body.style.cursor = 'default';
oXL.Visible = true;
var
oWB = oXL.Workbooks.Add();var
oSheet = oWB.ActiveSheet;oSheet. Cells(1, 1).AddComment("Test comment.");".
oSheet.Paste();
oXL.Visible = true;
oXL.UserControl = true;
Try to check out this document for more information about "Tips and Tricks for Scripting Microsoft Office Applications" - https://thesource.ofallevil.com/technet/scriptcenter/resources/officetips/may05/tips0531.mspx
Hope this helps,
Regards,
All Replies
Hi vinod,
If you would like to add comments to in some cells of an Excel file using javascript, you can try this code line - "oSheet. Cells(1, 1).AddComment("Test comment.");". The whole javascript sample codes as follows:
Code Blockthis.document.execCommand("SelectAll", false);
this.document.execCommand("Copy", true);
this.document.execCommand("UnSelect", false);
var
oXL = new ActiveXObject("Excel.Application");document.body.style.cursor = 'default';
oXL.Visible = true;
var
oWB = oXL.Workbooks.Add();var
oSheet = oWB.ActiveSheet;oSheet. Cells(1, 1).AddComment("Test comment.");".
oSheet.Paste();
oXL.Visible = true;
oXL.UserControl = true;
Try to check out this document for more information about "Tips and Tricks for Scripting Microsoft Office Applications" - https://thesource.ofallevil.com/technet/scriptcenter/resources/officetips/may05/tips0531.mspx
Hope this helps,
Regards,
- Hi I am getting an error near
" Automation server can't create object" near
var oXL = new ActiveXObject("Excel.Application");
i have done the changes as given by you in IE but still I have the same issue can you please help me out.
thnx in advance


