maedeh
maedeh

Reputation: 105

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];

Upvotes: 1

Views: 5934

Answers (2)

Akhila
Akhila

Reputation: 91

Hide any sheets in excel workbook using this code:

SourceWorksheet.Visible=Excel.XlSheetVisibility.xlSheetHidden;

Upvotes: 4

CodingYoshi
CodingYoshi

Reputation: 26989

Hide the window of the workbook:

SourceWorkbook.Windows[1].Visible = false;

Upvotes: 1

Related Questions