microsoft.interop.excel Formatting cells(microsoft.interop.excel 格式化单元格)
问题描述
我正在使用 C# 中的 microsoft.interop.excel 库构建报告.
I am building a report using the microsoft.interop.excel library in C#.
我有这样的事情:
Range rangeTarget;
.
.
.
rangeTarget = worksheet.get_Range("C" + row, "N" + row);
我希望范围将其值显示为整数,即没有小数位.我试过 rangeTarge.AutoFormat,但不知道如何使用它.
I want the range to display its values as whole numbers i.e. with no decimal places. I've tried rangeTarge.AutoFormat, but have no idea how to use it.
有什么想法吗?
谢谢.
推荐答案
参见 MSDN
Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
this.Controls.AddNamedRange(this.Range["A1", "A5"], "namedRange1");
namedRange1.NoteText("This is a Formatting test", missing, missing);
namedRange1.Value2 = "Martha";
namedRange1.Font.Name = "Verdana";
namedRange1.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter;
namedRange1.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
namedRange1.BorderAround(missing, Excel.XlBorderWeight.xlThick,
Excel.XlColorIndex.xlColorIndexAutomatic, missing);
namedRange1.AutoFormat(Excel.XlRangeAutoFormat.xlRangeAutoFormat3DEffects1,
true, false, true, false, true, true);
if (MessageBox.Show("Clear the formatting and notes?", "Test",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
namedRange1.ClearFormats();
namedRange1.ClearNotes();
}
这篇关于microsoft.interop.excel 格式化单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:microsoft.interop.excel 格式化单元格
基础教程推荐
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
