c# - Excel Interop 从右到左文档

标签 c# excel-interop worksheet direction

我用 C# 创建了一个新的 Excel 文件。

当我打开文档时,所有工作表都是从右到左对齐的。

如何对齐工作表/工作簿/窗口以按语法从左到右显示?

最佳答案

Sub leftToRight()
    Application.DefaultSheetDirection = xlLTR
    ActiveSheet.DisplayRightToLeft = False
End Sub

您还可以通过工具->选项->国际化 更改设置。请注意,您需要设置/取消设置复选框“从右到左查看当前工作表”才能更改当前打开的工作表。

编辑:抱歉,我不小心将您的问题解释为 VBA。

这是一个 C# 解决方案:

Excel.Application xlApp = new Excel.Application();
xlApp.Visible = true;
xlApp.Workbooks.Add(System.Type.Missing);  
Excel.Worksheet active = (Excel.Worksheet)xlApp.ActiveSheet;

xlApp.DefaultSheetDirection = (int)Excel.Constants.xlLTR; //or xlRTL
active.DisplayRightToLeft = false;

关于c# - Excel Interop 从右到左文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4594322/

相关文章:

.net - 在使用 C#.NET 生成的 Excel 工作表中显示页码

c# - 关闭 Excel 工作簿 - System.Runtime.InteropServices.COMException : Exception from HRESULT: 0x800A03EC

excel - Excel 何时以及如何重新计算其公式?

c# - 循环遍历 Excel 工作表并使用 C# 将文本保存到 TXT 文件中

c# - System.Web.Configuration.WebConfigurationManager 和 System.Configuration.ConfigurationManager 之间的行为差​​异

c# - 我是否在我的测试方法中 stub 或填充方法?

c# - 大文件传输中TcpClient VS Socket

c# - 使用 IF 语句处理 Enter 键

c# - 刷新 excel 文件,它使用 c# 从 sql server 获取数据

c# - 当我尝试在 Excel 工作表上运行查询时出现 "Invalid bracketing of name"错误