CReSharper
New Member
- Joined
- Jun 23, 2005
- Messages
- 2
So here is the situation. I have a Javascript program that takes a table and exports it to excel when the user clicks a button. That works cool.
The problem is that I have an embedded menu in the table that now gets exported into excel as the first four rows.
Here is the script:
function exportToExcel()
{
try{
var sHTML = document.all.ExploreGrid.outerHTML;
var sHTML2 = document.body.all.Annotations1.outerHTML;
var oXL = new ActiveXObject("Excel.Application");
var oBook = oXL.Workbooks.Add;
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML + sHTML2;
oBook.HTMLProject.RefreshDocument();
oXL.Visible = true;
oXL.UserControl = true;
}catch(er)
{
if(confirm('An error has occurred while trying to export to Excel. Possible causes are\n' +
' - Excel 2000 or higher is not installed on this PC\n' +
' - ActiveX controls are not enabled in your browser\n\n' +
'To view help on how to enable ActiveX controls, click OK.\n\n' +
'To continue without viewing help, click Cancel.')) +
window.open('InfoText.aspx?file=Help.htm#Supported Browsers');
}
}
The question I have is this, is there a way that once I have this into Excel that I can add some additional JS commands to delete the first four rows of the sheet? Maybe between the oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML + sHTML2; command and the oBook.HTMLProject.RefreshDocument();?
Anyone ever done this? Someone with intimate knowledge of the Excel Object Model should be able to answer this, I hope.
CRS
The problem is that I have an embedded menu in the table that now gets exported into excel as the first four rows.
Here is the script:
function exportToExcel()
{
try{
var sHTML = document.all.ExploreGrid.outerHTML;
var sHTML2 = document.body.all.Annotations1.outerHTML;
var oXL = new ActiveXObject("Excel.Application");
var oBook = oXL.Workbooks.Add;
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML + sHTML2;
oBook.HTMLProject.RefreshDocument();
oXL.Visible = true;
oXL.UserControl = true;
}catch(er)
{
if(confirm('An error has occurred while trying to export to Excel. Possible causes are\n' +
' - Excel 2000 or higher is not installed on this PC\n' +
' - ActiveX controls are not enabled in your browser\n\n' +
'To view help on how to enable ActiveX controls, click OK.\n\n' +
'To continue without viewing help, click Cancel.')) +
window.open('InfoText.aspx?file=Help.htm#Supported Browsers');
}
}
The question I have is this, is there a way that once I have this into Excel that I can add some additional JS commands to delete the first four rows of the sheet? Maybe between the oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML + sHTML2; command and the oBook.HTMLProject.RefreshDocument();?
Anyone ever done this? Someone with intimate knowledge of the Excel Object Model should be able to answer this, I hope.
CRS