更改Excel中单元格的对齐方式和分隔符分隔的数字位数(在c#中使用Excel) [英] Change alignment of Cell in Excel and separate number digits by separator (use Excel in c#)

查看:95
本文介绍了更改Excel中单元格的对齐方式和分隔符分隔的数字位数(在c#中使用Excel)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi
我使用DCOM Excel组件将我的数据导出到Excel。但我面临两个问题:

1-如何在单元格中设置文本对齐?将其设置为右,左或中心。例如worksheet.cell [1,2] .align =right;

2-假设包含一个单元格是一个数字。我想用分隔符(3位乘3位数)分隔它的数字,例如:34567898到34,567,898

非常感谢

Hi I Use DCOM Excel component for export my data to Excel . but I face to 2 problems:
1- How can I set align of a text in a cell ? set it to right , left or center. For example worksheet.cell[1,2].align = "right";
2- Suppose Contains of a cell is a number . I wants to separate it’s digits by separator (3 digits by 3 digits) for example : 34567898 to 34,567,898
Thanks very much

推荐答案

工作表.Cells [1,2] .Horizo​​ntalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;



我认为第二位的答案是



worksheet.Cells [1,2] .Style ="逗号" - 如果没有,则尝试单元格上的CellFormat.NumberFormat属性
worksheet.Cells[1, 2].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;

and I think the answer to the 2nd bit is

worksheet.Cells[1, 2].Style = "Comma" - if not then try the CellFormat.NumberFormat property on the cell


这篇关于更改Excel中单元格的对齐方式和分隔符分隔的数字位数(在c#中使用Excel)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆