简体   繁体   English

pentaho报告excel输出-前导'0'被截断

[英]pentaho report excel output - leading '0' gets truncated

I have a format issue with my pentaho report excel/csv output. 我的pentaho报告excel / csv输出出现格式问题。

My report output contains zip code column, which has leading zeroes if the zip code length is less than 5. the leading zeroes get truncated when i open the report output in excel file. 我的报告输出包含邮政编码列,如果邮政编码长度小于5,则其前导零。当我在excel文件中打开报告输出时,前导零会被截断。 I used 'textfield' for the zipcode column, i even tried concatenating zeroes in my xaction sql. 我在邮政编码列中使用了“文本字段”,甚至尝试在xaction sql中连接零。 everything works fine if i open the output in a text editor, but when we open it in excel file the zero got trimmed. 如果我在文本编辑器中打开输出,一切都会正常,但是当我们在excel文件中打开输出时,零被修剪了。

can we prevent this trimming issue or can we use other data fields in design instead of text field. 我们可以防止这种修整问题,还是可以在设计中使用其他数据字段代替文本字段。

Change the extension of your csv to .txt so you get Excel's dialogue boxes for importing text files; 将csv的扩展名更改为.txt,以便获得用于导入文本文件的Excel对话框; there you can select the comma as your column delimiter. 在那里,您可以选择逗号作为列分隔符。 On the third screen (after you hit "next" twice), there is an option to choose the formatting of each column. 在第三个屏幕上(单击“下一步”两次之后),可以选择每个列的格式。 Select you zip code column, change it from "General" to "Text" format, and your leading zeroes will be retained. 选择您的邮政编码列,将其从“常规”格式更改为“文本”格式,并将保留您的前导零。

use text formatting in the Home-->Number-->Special Cannt paste imapge--> i guess not enough points 在首页中使用文本格式->数字->特殊Cannt粘贴imapge->我猜没有足够的分数

Hope it helps 希望能帮助到你

我不知道它是否合适,但是将字段包含在双引号或您希望使用的单引号中。.引号不会以excel文件格式显示,但会显示在文本板或记事本中。因此您没有添加此多余的东西有任何问题,那么它将解决您的问题。

What is the original data format in your DB? 数据库中的原始数据格式是什么? Is it an INT? 是INT吗? In your sql statement, try something like this (adjust for the relevant sql dialect, if necessary): 在您的sql语句中,尝试执行以下操作(如有必要,请调整相关的sql方言):

lpad(cast(zip as CHAR(5)),5,'0') zip

where zip is your field name. zip是您的字段名称。 Then use text-field as you are already doing. 然后,如您所愿地使用文本字段。

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

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