如何使用 JXL 创建从右到左对齐的 Excel 工作表
我想知道是否可以将Excel工作表的方向设置为从右到左... 我正在使用 JXL Api。
提前致谢
赏金是从右到左对齐,而不是右对齐
I wonder if i can set the direction of the excel sheet to right-to-left ...
I am using JXL Api.
thanks in advance
The bounty is about right to left and not right alignment
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
目前 JXL 不支持此选项,但如果您愿意编辑和重新构建 JXL,我有一个很好的解决方案。
从右到左的选项在名为 WINDOW2 记录的文件部分中保存和定义。您可以在此处中查看部分中定义的所有选项第 5.110 节窗口2。在 5.110.2 选项标志部分下,您可以看到选项标志的掩码值和从右到左的选项:
JXL create 此类中 excel 文件的这一部分 - Window2Record。
在构造函数方法中,您可以看到有些值是可配置的,有些是硬编码的:
如您所见,选项“显示轮廓符号”被硬编码为 true,因为它的掩码(0x80)始终添加到选项标志中,并且 DisplayZeroValues 可以通过给定 SheetSettings 对象(具有 getter 和 setter...)的值进行配置。
如果您愿意重建项目,您可以通过添加以下行来硬编码从右到左的设置:
到此构造函数,或者如果您希望它可配置,请向 SheetSettings 添加一个新参数(及其 getter 和 setter),并在 Window2Record 中为其添加右侧的 if 子句。
Currently JXL does not support this option, but I have a good solution that will work if you are willing to edit and re-build JXL.
Right-to-left options are saved and defined in a section of the file called WINDOW2 record. You can see all the options defined in the part here in section 5.110 WINDOW2. Under section 5.110.2 Option Flags, you can see the mask value for the option flag and the right-to-left option:
JXL create This part of the excel file in this class - Window2Record.
In the constructor method you can see that some of the values are configurable and some are hard-coded:
As you can see options "display outline symbols" is hard coded to be true, since it's mask (0x80) always added to the options flag, and DisplayZeroValues is configurable by the values of the given SheetSettings object (that has getter and setters...)
If you are willing to rebuild the project, you can either hard code your right-to-left settings by adding the line:
to this constructor, or if you want it configurable, add a new parameter to the SheetSettings (and a getter and a setter for it) and in the Window2Record add the right if clause for it.
这可以手动完成 (来自 Microsoft Office 支持)
JXL api 似乎不支持此功能。您可以查看 Apache Poi (javadoc) 或 TeamDev 的 JExcel (javadoc) 更适合这种需求。实现方式将类似于:
Poi 方式:
通过 Jexcel:
关于 poi:1, 2,3。
顺便说一句,如果您尝试使用
setExcelRegionalSettings(IL)
或setExcelRegionalSettings(IL-JM)
将不起作用,因为这些是 JXL 唯一支持的国家/地区:This can be done manually (from Microsoft Office Support)
It seems JXL api doesn't support this feature. You can have a look at Apache Poi (javadoc) or TeamDev's JExcel (javadoc) which is more appropriate for this kind of requirement. Implementation will be similar to these:
Poi way:
Via Jexcel:
About poi: 1, 2, 3.
Btw, if you try the use
setExcelRegionalSettings(IL)
orsetExcelRegionalSettings(IL-JM)
is not going to work because these are the only supported countries by JXL:要在电子表格创建过程中设置从右到左的方向:
当您希望在 Jexcel 中创建新的电子表格时:
调用工作表方法来创建一个新工作表作为工作表模板的副本。这是 Workbook 类中的方法:
使用给定文件名创建可写工作簿作为工作簿的副本
传入。创建后,可写工作簿的内容可以修改
创建后更改方向:
您可以手动创建一个名为 AUTO_OPEN 的 Excel 宏,该宏将在电子表格打开时运行:< /p>
<预><代码> Application.DefaultSheetDirection = xlRTL
ActiveSheet.DisplayRightToLeft = True
或者您可以使用 JXL 进行所有处理,关闭文件,然后运行 VBscript(与microsoft.office.interop.excel.dll):
您可以通过Process<从java执行脚本/a>
To set right-to-left direction during Spreadsheet creation:
When you wish to create a new spreadsheet in Jexcel:
invoke the worksheet method to create a new worksheet as a copy of the worksheet template. Here's the method in Workbook class:
Creates a writable workbook with the given filename as a copy of the workbook
passed in. Once created, the contents of the writable workbook may be modified
To change direction after creation:
you can manually create an excel macro called AUTO_OPEN that will run whenever the spreadsheet is open:
or you can do all your processing with JXL, close the file and then run a VBscript (interfacing with microsoft.office.interop.excel.dll):
You can execute a script from java via Process