作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的服务器人员还没有准备好安装 office
我在表单中编写了以下代码。它在我的机器上运行良好,但是当我上传到网上时;这是行不通的。这需要 interop dll 但服务器人员尚未准备好在服务器上安装 office。任何人都可以帮助我,因为我需要从 excel 中取消隐藏工作表。
使用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();
最佳答案
使用 Open XML SDK 并将 Sheet
的 State
属性设置为 SheetStateValues.Hidden
。
Sheet.State 属性
http://msdn.microsoft.com/en-us/library/office/documentformat.openxml.spreadsheet.sheet.state.aspx
用于 Microsoft Office 的 Open XML SDK 2.5
http://www.microsoft.com/en-us/download/details.aspx?id=30425
不要在服务器上使用办公自动化。
关于c# - 如何在不使用互操作的情况下通过 C# 取消隐藏 Excel 工作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18440744/
我是一名优秀的程序员,十分优秀!