我在将一系列合并单元格水平居中对齐时遇到问题。对齐方式保持在左侧。这是我的代码。
ws.Cells[lStartColumn + lStartRow].Value = gPortfolioName + " - " + lTypeOfPortfolioPerf + " Performance Update";
ws.Cells[lStartColumn + lStartRow + ":" + lEndColumn + lEndRow].Merge = true;
ws.Cells[lStartColumn + lStartRow + ":" + lEndColumn + lEndRow].Style.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous;
ws.Cells[lStartColumn + lStartRow + ":" + lEndColumn + lEndRow].Style.Font.Size = 14;
ws.Cells[lStartColumn + lStartRow + ":" + lEndColumn + lEndRow].Style.Font.Color.SetColor(bgTitleColor);
ws.Cells[lStartColumn + lStartRow + ":" + lEndColumn + lEndRow].Style.Font.Bold = true;
最佳答案
应该是:
worksheet.Cells["A2:A4"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
但我认为你应该最后做,因为一些样式更改会影响你的对齐方式。顺序很重要。
关于c# - 如何在 EPPlus 中水平对齐居中合并单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27360806/