简体   繁体   English

使用EPPlus在选择中居中

[英]Centering Across Selection Using EPPlus

If you select adjacent cells in excel and click 'Format Cells', within the alignment tab you can set text alignment to 'Center Across Selection'. 如果您在excel中选择相邻的单元格并单击“设置单元格格式”,则可以在对齐选项卡中将文本对齐方式设置为“居中选择中心”。

Is there a way to apply this programatically using EPPlus? 有没有办法使用EPPlus以编程方式应用此方法? I searched on their official documentation and couldn't find anything. 我搜索了他们的官方文档,但找不到任何东西。 If there is no way to apply this through EPPlus, what is the best alternative? 如果没有办法通过EPPlus应用此方法,最好的替代方法是什么?

The use case is that I need to traverse through cells in one particular row in excel and turn duplicate entries into one entry centered across the cells. 用例是我需要遍历excel中某一特定行中的单元格,并将重复的条目转换为一个跨单元格居中的条目。 The logic I had in mind is to delete the content in all bar the first cell and then center across a selection of all the cells. 我想到的逻辑是删除第一个单元格所有栏中的内容,然后将所有单元格的选定部分居中。

EPPlus支持此使用CenterContinuous是这样的:

ws.Cells[1, 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM