简体   繁体   English

使用后期绑定用逗号分隔的数字字符串将数据写入excel会转换为数字格式

[英]Write data to excel using Late binding comma-separated number strings are converted to number format

I have a property named Year and its value can selected multiple like 2017, 2016, but when we write this value to excel it automatically converted to Number format like 201,62,017. 我有一个名为Year的属性,它的值可以选择多个,例如2017、2016,但是当我们将此值写入excel时,它会自动转换为Number格式,例如201,62,017。

So I need to set the cell format to Text before writing the value. 因此,我需要在写入值之前将单元格格式设置为“文本”。

I need the solution using Late Binding. 我需要使用后期绑定的解决方案。 I only find the below code: 我只找到以下代码:

oRange.GetType().InvokeMember("NumberFormat", BindingFlags.SetProperty, null, oRange, oParams);

This is for set the range as NumberFormat, Right? 这是用于将范围设置为NumberFormat,对吗?

Please help!!!! 请帮忙!!!!

似乎是正确的,并且要设置“文本”单元格格式,应这样称呼:

oRange.GetType().InvokeMember("NumberFormat", BindingFlags.SetProperty, null, oRange, new object[] {"@"});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM