使用EPPlus转换成整数,在Excel(asp.net) [英] converting into integer in excel using EPPlus (asp.net)

查看:1635
本文介绍了使用EPPlus转换成整数,在Excel(asp.net)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 LoadFromDataTable 则方法改变单元格的格式为整数仍是示值误差将数据加载到Excel中的数据表,在此单元格中的数字的格式为文本或$ p $由撇号pceded

I am loading data into excel from datatable using LoadFromDataTable method then changed cell format to integer still it is showing error "The number in this cell is formatted as text or preceded by apostrophe".

电池显示只有右侧和数字格式只在单元格属性。

cell was showing to right side only and number format only on cell property.

还是我不理解为什么我收到这个错误??

still I am not understanding why I am getting this error??.

Dim wsManufacturing As ExcelWorksheet = pck.Workbook.Worksheets.Add("Manufacturing")
wsManufacturing.Cells("A1").LoadFromDataTable(dtManufacturing, True)
 Using col As ExcelRange = wsManufacturing.Cells(2, 2, 2 + dtManufacturing.Rows.Count, 2)
    col.Style.Numberformat.Format = "#,##0"
    col.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right
 End Using

推荐答案

您可以这样做:

//strValue="98.5%";
double realValue=double.Parse(strValue.Replace("%", string.Empty));
Worksheet.Cells[row + 1, col].Style.Numberformat.Format = "#0\\.00%";
Worksheet.Cells[row + 1, col].Value = realValue;

这篇关于使用EPPlus转换成整数,在Excel(asp.net)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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