找回密码
 立即注册

QQ登录

只需一步,快速开始

wangyiwangyi

中级会员

16

主题

68

帖子

696

积分

中级会员

积分
696
wangyiwangyi
中级会员   /  发表于:2018-1-5 16:56  /   查看:4028  /  回复:7
单元格设置 DoubleCellType 如下,数据导出后整数后会出现一个点,如何解决?

FarPoint.Web.Spread.DoubleCellType DoubleCellType = new FarPoint.Web.Spread.DoubleCellType();
                    int nDecimalDigits = 2;
                    Int32.TryParse(OneWeb.DataExt, out nDecimalDigits);
                    DoubleCellType.DecimalDigits = nDecimalDigits;
                    DoubleCellType.MaximumValue = 10000000000;
                    DoubleCellType.MinimumValue = -10000000000;

                    // 科学计数法处理
                    System.Globalization.NumberFormatInfo CellFormat = new System.Globalization.NumberFormatInfo();
                    CellFormat.NumberDecimalDigits = 4;
                    CellFormat.NumberGroupSizes = new int[] { 0 };

                    DoubleCellType.NumberFormat = CellFormat;
                    FpSpread1.Sheets[OneWeb.SheetIndex].Cells[OneWeb.RowNum, OneWeb.ColNum].CellType = DoubleCellType;

页面加载正常显示:
image.png202211302.png
数据导出:123整数后会有一个点,
image.png206199340.png

数据导出方法用的是
// 报表保存到Excel文件XLS
FpSpread1.SaveExcel(fileName);


7 个回复

倒序浏览
Clark.Pan讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2018-1-8 17:57:27
沙发
您好:
请问您用的是V10版本还是V11版本?
回复 使用道具 举报
wangyiwangyi
中级会员   /  发表于:2018-1-9 09:11:49
板凳
V10版本
回复 使用道具 举报
wangyiwangyi
中级会员   /  发表于:2018-1-9 10:49:47
地板
是V10版本
回复 使用道具 举报
Clark.Pan讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2018-1-9 18:09:49
5#
好的,我这边试一下给您答复。
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2018-1-10 10:40:51
6#
您好,这个是因为设置了 CellFormat.NumberDecimalDigits = 4,导致了单元格格式设置为“0.####”所以在Excel里显示时候有问题了。
您现在是想设置一个什么样的格式,看看是否有其他方式可以设置。
回复 使用道具 举报
wangyiwangyi
中级会员   /  发表于:2018-1-23 11:09:38
7#
// 科学计数法处理
                    System.Globalization.NumberFormatInfo CellFormat = new System.Globalization.NumberFormatInfo();
                    CellFormat.NumberDecimalDigits = 4;
                    CellFormat.NumberGroupSizes = new int[] { 0 };

如果不加以上代码,数据以科学计数法显示了,加入后导出数据整数后有个点,请问有好的解决方法吗?
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2018-1-23 15:35:07
8#
您设置下
            DoubleCellType.FixedPoint = true;
这样会往后自动补0

评分

参与人数 1满意度 +5 收起 理由
wangyiwangyi + 5 很给力!

查看全部评分

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部