How to make Excel Sheet Visible Programmatically i

2019-08-29 07:23发布

I am developing an Excel Report in C#. I have the input and the configuration settings in the Excel file and I generate the output report in Excel as well.

So, there will be 3 Excel Files open in the program. So, this is how I do it through single Excel object :

Excel._Workbook inputWb = oXL.Workbooks.Open(ExcelFileName, misval, misval, misval, misval, misval, misval, misval, misval, misval, misval, misval, misval, misval, misval);
Excel._Worksheet inSheet = inputWb.Sheets["Input"];

Excel._Workbook configWb = oXL.Workbooks.Open(ConfigFile, misval, misval, misval, misval, misval, misval, misval, misval, misval, misval, misval, misval, misval, misval);
Excel._Worksheet configSheet = configWb.Sheets[1];

Excel._Workbook outputWb = (Excel._Workbook)(oXL.Workbooks.Add(misval));
Excel._Worksheet outSheet = outputWb.Sheets[1];

Now, I would like to make just the output Excel file Visible. Any idea how do it ?

Thanks

标签: c# excel
2条回答
贪生不怕死
2楼-- · 2019-08-29 07:41

You can hide individual worksheets, but you can also hide a workbook. In VBA:

    Workbooks(2).Windows(1).Visible = False

or

Workbooks.Open Filename:="C:My Documents\Hide Test.xlsx"
Windows("Hide Test.xlsx").Visible = False

Change this setting to True before saving or closing the workbook (if appropriate).

查看更多
SAY GOODBYE
3楼-- · 2019-08-29 07:49

oXL.Visible = true; should show the Excel file you are dealing with.

查看更多
登录 后发表回答