求助_报表中对数据的格式化可否保留并显示在自定义报表里及导出excel后保留数字形式的小数_产供销
学习.交流
专业源于专注
www. onlyit. cn   
学习交流 文件下载 手册资料 交流QQ群

    

 1  1/1   1  
作者
内容
cathy  [个人空间]


注册  2007-07-18
发贴数  222
精华数  0
原创贴  0
来自  
状态  正常

级别  会员
#1»发布于2023-01-14 22:41

比如,用 select cast('12.36' as decimal(14,4))  
 
正常是有显示补齐的小数位的,但当显示在 自定义报表(脚本报表里),小数位后的0被自动抹掉了。 
 
问题1: 
能否保留格式化的数字并显示在报表MG里? 
 
问题2: 
当导出为excel时,能否保留为数字形式的补齐0的小数位,类似于作了NumberFormatlocal 
 
//测试代码 
//建表: 
 
-- ---------------------------- 
-- Table structure for test_fee 
-- ---------------------------- 
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[test_fee]') AND type IN ('U')) 
  DROP TABLE [dbo].[test_fee] 
GO 
 
CREATE TABLE [dbo].[test_fee] ( 
  [sn] int  NULL, 
  [fee] decimal(14,4)  NULL 

GO 
 
ALTER TABLE [dbo].[test_fee] SET (LOCK_ESCALATION = TABLE) 
GO 
 
-- ---------------------------- 
-- Records of test_fee 
-- ---------------------------- 
INSERT INTO [dbo].[test_fee] ([sn], [fee]) VALUES (N'1', N'12.3000') 
GO 
 
INSERT INTO [dbo].[test_fee] ([sn], [fee]) VALUES (N'2', N'15.2360') 
GO 
 
INSERT INTO [dbo].[test_fee] ([sn], [fee]) VALUES (N'3', N'13.2156') 
GO 
 
INSERT INTO [dbo].[test_fee] ([sn], [fee]) VALUES (N'4', N'26.3250') 
GO 
 
 
//脚本报表 
string change_obj; 
int obj_change() 

  return 1; 
}; 
 
int func_can_run() 

  return 1; 
}; 
 
int func_def_lmt() 

  def_lmt_str("sl", "数量"); 
  return 1; 
}; 
 
int func_init_lmt_val() 

  return 1; 
}; 
 
int func_def_field() 

  db_set_field_count(db_field_count()); 
  return 1; 
}; 
 
int func_def_imp() 

  return 1; 
}; 
 
int func_init() 

  return 1; 
}; 
 
int func_query() 

  string sql, sl; 
  sl = gui_get_val("edit_sl"); 
  sql = "select "; 
  if (sl != "") 
  {sql = sql + " top " + sl;} 
  sql = sql + "  sn,cast(fee as decimal(14,4))as fee from test_fee"; 
  db_run(sql); 
  return 1; 
}; 
 
int func_run_over() 

  int a, b; 
  string bq; 
  b = grid_row_num('MG'); 
  for (a = 1; a <= b; a++) 
  { 
    bq = str_std_num(grid_get_v('MG', 'fee', a), 4); 
    grid_set_v('MG', 'fee', a, bq); 
  } 
  grid_set_col_number('MG', 'fee', 4); 
  return 1; 
}; 
 
int func_dbl_click() 

  return 1; 
};




        于 2023-01-14 22:41 被 cathy 修改



 1  1/1   1  

登录后方可发贴


[ 电话: 0571-85462761 王先生 QQ: 124520435 加入软件QQ群 - 杭州 - 浙ICP备19051128号-1 网安 33010402003225 ]