简体   繁体   中英

How to unhide an excel sheet through c# without using interop

My server guy is not ready to install office

I have written the following code in my form. It works fine from my machine but when I upload on the net; it does not work. This requires the interop dlls but the server guy is not ready to install office on the server. can any one help me as I need to unhide sheet from excel .

using excel;

        Excel.Application excelApp = new Excel.Application();

        string myPath = @fileLocation;
        excelApp.Workbooks.Open(myPath, Missing.Value, Missing.Value,Missing.Value, Missing.Value,Missing.Value, Missing.Value,Missing.Value, Missing.Value,Missing.Value, Missing.Value,Missing.Value, Missing.Value);//,Missing.Value, Missing.Value);

        //Get the first sheet.
        Excel.Worksheet objSheet = (Excel.Worksheet)excelApp.ActiveWorkbook.Sheets["abc"];

        //Unhide the worksheet.
        objSheet.Visible = Excel.XlSheetVisibility.xlSheetVisible;
        //Save As the Excel file.
        excelApp.ActiveWorkbook.Save();

Use Open XML SDK and set the Sheet 's State property to SheetStateValues.Hidden .

Sheet.State property

http://msdn.microsoft.com/en-us/library/office/documentformat.openxml.spreadsheet.sheet.state.aspx

Open XML SDK 2.5 for Microsoft Office

http://www.microsoft.com/en-us/download/details.aspx?id=30425

Don't use office automation on a server.

在此输入图像描述

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