microsoft.interop.excel设置单元格 [英] microsoft.interop.excel Formatting cells

查看:666
本文介绍了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设置单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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