有人知道如何让传递到工作表的内容正确对齐吗?
发布于 2014-03-20 22:30:09
如果要对齐一个单元格,请使用
worksheet.Cells[y, x].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;如果要对齐多个
worksheet.get_Range("A1", "A30").Style.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;如果您不能使用Microsoft.Office.Interop.Excel,那么我不是很确定,但是您可以尝试使用ExcelCellStyle
ExcelCellStyle titleStyle = workbook.Styles.AddStyle("WorksheetTitleStyle");
// align the text
titleStyle.Alignment.HorizontalAlignment = ExcelCellHorizontalAlignmentType.right;
titleStyle.Alignment.VerticalAlignment = ExcelCellVerticalAlignmentType.Center;你可以在这里找到更多:http://www.winnovative-software.com/ExcelLibDemo/RangesAndCells.aspx
发布于 2020-01-01 17:17:28
using ClosedXML.Excel;
using (ClosedXML.Excel.XLWorkbook wb = new ClosedXML.Excel.XLWorkbook())
{
var ws = wb.Worksheets.Add("WorkSheetName");
ws.Range(firstCellRow, firstCellColumn, lastCellRow, lastCellColumn).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;
}如果要在工作表中右对齐特定部分
https://stackoverflow.com/questions/22535769
复制相似问题