单元格值在excel中读作####

时间:2022-04-06 22:19:58

I am reading a cell value from excel using named range in my case sometime the column width is smaller then the value that is present in the cell and hence it is appearing as ##### when it is huge number.

在我的情况下,我正在使用命名范围从excel读取单元格值,有时列宽度小于单元格中存在的值,因此当它是大数字时它显示为#####。

when i read this from csharp it is reading as #####. Any fix for this

当我从csharp读取它时,它读作#####。对此有任何修复

Sample code:

示例代码:

Excel.Application.get_Range(strRange, Type.Missing).Text.ToString() //If i make it 
Excel.Application.get_Range(strRange, Type.Missing).Value2.ToString() //and read any date string i get 40390

3 个解决方案

#1


3  

Without having any code to read I would guess that you are reading a display string or similar, which Excel will update each time the row width varies.

没有任何代码可以阅读,我猜你正在读一个显示字符串或类似的,每次行宽变化时Excel将更新。

You probably need to be reading a more raw value.

您可能需要阅读更原始的价值。

#2


2  

.Text gives you whatever you see as formatted in the Excel rendering layer (so #### if the column is too small) .Value2 gives you the underlying Excel value.

.Text为您提供在Excel渲染层中格式化的内容(如果列太小,则为####).Value2为您提供基础Excel值。

Date/times in Excel are stored internally as numbers representing the number of days since Year 1900 Jan 0 plus a decimal part representing a fraction of 24 hours for the time, so your date is coming through as an integer.

Excel中的日期/时间在内部存储为数字,表示自1900年1月0日以来的天数以及表示该时间的24小时的小数部分,因此您的日期将以整数形式出现。

If you want to convert the number back into a date you can use Format: for example format(40390,"ddmmyyyy") or format(40390,"dd/mmm/yyyy")

如果要将数字转换回日期,可以使用格式:例如格式(40390,“ddmmyyyy”)或格式(40390,“dd / mmm / yyyy”)

#3


0  

Are you perhaps trying to import negative dates? Excel doesn't handles these well, processing dates as doubles usually works though.

您是否尝试导入负日期? Excel不能很好地处理这些,处理日期虽然双打通常有效。

#1


3  

Without having any code to read I would guess that you are reading a display string or similar, which Excel will update each time the row width varies.

没有任何代码可以阅读,我猜你正在读一个显示字符串或类似的,每次行宽变化时Excel将更新。

You probably need to be reading a more raw value.

您可能需要阅读更原始的价值。

#2


2  

.Text gives you whatever you see as formatted in the Excel rendering layer (so #### if the column is too small) .Value2 gives you the underlying Excel value.

.Text为您提供在Excel渲染层中格式化的内容(如果列太小,则为####).Value2为您提供基础Excel值。

Date/times in Excel are stored internally as numbers representing the number of days since Year 1900 Jan 0 plus a decimal part representing a fraction of 24 hours for the time, so your date is coming through as an integer.

Excel中的日期/时间在内部存储为数字,表示自1900年1月0日以来的天数以及表示该时间的24小时的小数部分,因此您的日期将以整数形式出现。

If you want to convert the number back into a date you can use Format: for example format(40390,"ddmmyyyy") or format(40390,"dd/mmm/yyyy")

如果要将数字转换回日期,可以使用格式:例如格式(40390,“ddmmyyyy”)或格式(40390,“dd / mmm / yyyy”)

#3


0  

Are you perhaps trying to import negative dates? Excel doesn't handles these well, processing dates as doubles usually works though.

您是否尝试导入负日期? Excel不能很好地处理这些,处理日期虽然双打通常有效。