简体   繁体   中英

visible and hide specific excel sheet in C#

this is my variables and my input and result excel file are in different workbooks and I want to show the output workbook only. I want to show Targetworkboo1 in output but with this code, sourceworkbook and Targetworkbook1 will be shown in output. how should I do it?

Excel.Application xlApp = new Excel.Application();
Excel.Workbook SourceWorkbook;
xlApp.Visible = true;
Excel.Workbook TargetWorkbook1;
Excel.Worksheet SourceWorksheet;
Excel.Worksheet TargetWorksheet1;
SourceWorksheet = SourceWorkbook.Worksheets[1];
TargetWorkbook1 = xlApp.Workbooks.Add();
TargetWorksheet1 = TargetWorkbook1.Worksheets[1];

隐藏工作簿的窗口:

SourceWorkbook.Windows[1].Visible = false;

使用以下代码隐藏excel工作簿中的所有工作表:

SourceWorksheet.Visible=Excel.XlSheetVisibility.xlSheetHidden;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM