从JavaScript代码隐藏Excel选项卡
作者:互联网
如何通过Javascript以编程方式隐藏Excel选项卡.
ExcelSheetName.Visible = False似乎不起作用.我在Google上搜索了很多,但没有收到正确的解决方案.怎么做 ?
解决方法:
若要隐藏Excel工作表,请将相应的工作表对象的Visible属性设置为0或false.
例如,如果您有一个包含两个名为Sheet1和Sheet2的工作表的Excel文件,则以下代码将在隐藏Sheet1的情况下打开该文件:
var objExcel = new ActiveXObject("Excel.Application");
objExcel.Visible = true;
objExcel.Workbooks.Open("C:\\Book1.xlsx");
objExcel.ActiveWorkbook.Sheets("Sheet1").Visible = false;
// You can aslo use this --
//objExcel.ActiveWorkbook.Sheets("Sheet1").Visible = 0; // xlSheetHidden
So I said as u pointed out. This is my code:
06001
But on doing so, I get the error as Unable to set the Visible property of the Worksheet class. Any clue what could be the possible error ?
该错误是因为CSV文件在Excel中只有一个标签,而您不能隐藏唯一的可见标签.至少1个标签必须始终可见.
标签:jscript,wsh,javascript,excel 来源: https://codeday.me/bug/20191009/1878651.html