How to retain leading zeros in an excel sheet
Hi,
In my application I need to export the response from a struts action class to an excel sheet. I have done the coding but while exporting to the excel , the leading zeros are getting truncated. If the value is '01' it is displayed as '1' only.
response.setContentType("application/text");
response.setHeader("Content-disposition",
"Attachment;filename=\"export.xls\"");
response.getOutputStream().println(data);
response.getOutputStream().flush();This is the code which I am using to export all the data to the excel.Here the variable data is a String .
Kindly help on this issue.
Thanks in advance...
Edited by: 2569 on Jan 10, 2008 8:59 PM
Edited by: 2569 on Jan 10, 2008 9:51 PM
2569 wrote:
I tried that way also, but its not working. I have defined all the values as strings only. Thanks for ur replyWhich API are you using to write excel files? You can try to surround the numeric string value with singlequotes (or escaped doublequotes)String numericString = "'01'";so that Excel interprets it as string.
Similar Messages
-
Need leading Zeros in the excel sheet which is sent from ABAP
Hi ,
I am downloading data from SAP to excel sheet using the WS_DOWNLOAD Function Module. The numeric data in not having leading zeros. if it is 0010 it is displaying 10 in the excel sheet . i need the leading zeros in the excel sheet. without manulally changing it to Text in the excel sheet .
Is there any way to do it .
Thanks,
ChetanHi Chetan,
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
filename = w_file_path
filetype = 'DBF' "declare the File type as DBF then leading zeros will appear
write_field_separator = 'X'
confirm_overwrite = 'X'
TABLES
data_tab = Itab.
Regards,
Prabhudas -
How to retain leading zeros in module pool screen
Hi experts,
I have a ztable field of type NUMC4 being displayed on a module pool screen, the value in the field is '0001', but on the screen it displays value as '1' (without leading zeros), When I save the record, Even in the databse it stores as '1'.
But I have checked in debugging the field always contains '0001' in the program execution and I have also used 'CONVERSION_EXIT_ALPHA_INPUT' in the PBO but no use.
Pls suggest.
Thanks,
DeepakCheck the screen attributes for the field. There is an option to show leading zeroes.
edit.
And how did you see it was stored a 1 and not 0001? Using SE16N? Mind you: with SE16N conversion-exits are executed automatically thus showing 0001 as 1.
To make sure: double click on the record in SE16N and look if it's still 1 and not 0001. -
Leading zeros in downloaded excel
Hi,
I'm facing a problem with truncated leading zeros in downloaded excel. Can anybody suggest me how to get those leading zeros in excel.
I tried Function modules XXL_FULL_API and WS_DOWNLOAD, both did not work.
Regards,
PraveenaHi Praveena,
check the following code.
data : begin of itab occurs 0,
matnr like mara-matnr,
maktx like makt-maktx,
matnr2 like mara-matnr,
end of itab.
itab-matnr = '00000011111'.
itab-maktx = 'test1'.
itab-matnr2 = '00000011112'.
append itab.
itab-matnr = '00000033333'.
itab-maktx = 'test2'.
itab-matnr2 = '00000044444'.
append itab.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = ' '
CODEPAGE = ' '
FILENAME = 'D:\c.xls '
FILETYPE = 'WK1'
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
TABLES
data_tab = itab
FIELDNAMES =
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
nagaraj -
Hi,
We are exporting the output in CSV format but CSV is not showing leading zeros.
For example - if the value is 0002 then it appears as 2 in CSV.
Is there any method or trick to retain leading zeros.
Although, this can be done through excel macro(after the file is opened) but for that manual intervention is required.
Is there any way to run excel macro through web page ? I mean if we could automate the procedure of running macro.
so that user just clicks on the button "Export to CSV" on web page and he gets the output in Excel with leading zeros retained.
Regards,
AnilHi Jeremy,
Although i am building a string in BLS and writing it into a csv file
but I tried to test your statement by simulating with test data
For one column of "VARCHAR2" datatype, the value is '0002'
when i test the query results with text/xml output, the SQLDataType="12"
and the value is 0002
but when i test the query results with text/csv output, the value is 2.
Regards,
Anil -
Retaining leading zero after sum operation
I have a variable g = 00000005. Now when I am adding g = g + 1.
The result is coming 6 but without leading zeroes.How could I retain leading zero after sum operation.Hi Priya,
Declare the g as type N.. then do sum.. okay..
ex :
data : d(7) type n value '0000005'.
g = g + 1.
write : g.
output is : 0000006.
Raghunath.S -
How to remove leading zero from Material Number
Hello Everyone,
I need to figure it out how to remove leading zero from material number. Cureently extractor is sending material number as 100663. But when comes into BI i am getting as "000000000000100663" and similariy in report it is appearing as "000000000000100663". Now my client wants me to exclude preceeding zero for a material in all the reports.
Is there any setting in query desinger to handle this issure or in the backend.
Need your inputs.
Thanks,
Lasya.Hi
you can use the function Module
CONVERSION_EXIT_ALPHA_OUTPUT in the start routine
to test this go to SE37 --- give the CONVERSION_EXIT_ALPHA_OUTPUT -
>display -
> F8
in the input give 000000456
and execute
the out put will be 456
for getting Zeros you can use
CONVERSION_EXIT_ALPHA_INPUT--- to remove leading zeros
Santosh
Edited by: Santhosh Nagaraj on Oct 29, 2009 10:52 PM
Edited by: Santhosh Nagaraj on Oct 29, 2009 10:54 PM -
How to remove leading zeros from variable
hi,
how to remove leading zeros from variable like it_vbap-matnr.
value in it_vbap-matnr is 000000000000000358
i want to remove leading zeros so that it become 358
regards
deepakYou can use Function Module <b>'CONVERSION_EXIT_MATN1_OUTPUT'</b>
This Function Module will eliminate leading Zeros.
For each MATNR Value read form DB Table,u can eliminate Leading zeros and then modify ur Internal table.
I think u will not get leading Zeros into utr Internal table when u read from VBAP.
Bcoz MATNR in VBAP itself have Conversion routine.
If u r getting leading zeros,U can use following Logic.
tables:
vbap.
data:
t_vbap like standard table of vbap.
select matnr
from vbap
into corresponding fields of table t_vbap.
loop at t_vbap into vbap.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
EXPORTING
INPUT = vbap-matnr
IMPORTING
OUTPUT = vbap-matnr
modify t_vbap from vbap transporting matnr.
endloop.
Hope this will work..... -
How to remove leading zeros for an item number within quickviewer
how to remove leading zeros for an item number within quickviewer. Pls help
ask your abap guy to do it. not portal guys business.
-
How to delimit leading zero in vendor number in OO ABAP ALV without using conversion routine
Hi,
How to delimit leading zero in OO ABAP ALV without using conversion routine, because I have many fields like vendor, customer, material number etc..
How to address this leading zero.
I appreciate your quick response.
Regards,
Nalini S.Hi Nalini,
Delimiting leading zeros in fields has to be done via conversion routines, as suggested by Vadamalai you need to pass on the conversion routine name in you field catalog variable.
Now as to which object oriented approach are you using to have your table contents display in ALV as it matters -
Using FACTORY method of CL_SALV_TABLE class, or
Using SET_TABLE_FOR_FIRST_DISPLAY method of CL_GUI_ALV_GRID class.
Using FACTORY method of CL_SALV_TABLE will do your own work, no need to apply any conversion routines or set long/medium/short text for columns as we do in field catalogs!
Cheers,
Varun -
Hi,
How to suppress leading zeros in a character string.
Thank you.hi,
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = str1
IMPORTING
output = str1.
Example:
input = 00000000000123
output = 123
rgds
Anver -
How to populate the Quering data into Excel sheet in Oracle
Dear Guys,
How to populate the Quering data into Excel sheet in oracle.
Please provide a solution.
Thanks & Regards,
Senthil K KumarHi
To make Excel sheets from sqlplus, you can use the markup html tag in sqlplus.
Here's an example.
Example
<code>
SET LINESIZE 4000
SET VERIFY OFF
SET FEEDBACK OFF
SET PAGESIZE 999
SET MARKUP HTML ON ENTMAP ON SPOOL ON PREFORMAT OFF
SPOOL c:\test_xls.xls
SELECT object_type
, SUBSTR( object_name, 1, 30 ) object
, created
, last_ddl_time
, status
FROM user_objects
ORDER BY 1, 2
SPOOL OFF
SET MARKUP HTML OFF ENTMAP OFF SPOOL OFF PREFORMAT ON
SET LINESIZE 2000 VERIFY ON FEEDBACK ON
</code> -
How to send ALV output data into Excel sheet format via Mail to the user?
Hi friends,
I have a doubt ie,
How to send ALV output data into Excel sheet format via Mail to the user?
regards
MoosaHi,
Provide the output internal table to the objbin in the below FM
Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = i_docdata
put_in_outbox = c_x
TABLES
packing_list = i_objpack
object_header = i_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
and specify the document type
i_objpack-doc_type = 'XLS'.
and try.
Regards,
Nandha -
Export jsp content to Excel -- how to keep leading zero?
Hi:
I am trying to export a JSP content to Excel by using
response.setContentType( "application/vnd.ms-excel" );
response.setHeader( "Content-disposition", "attachment; filename=pc.xls" );
it was working great except my jsp has a field whose value consist of leading zero. i.e. 000XXX. Excel strips the leading zero, but I would like to keep them. Please advise.hi Chang,
Can you please check my thread http://forum.java.sun.com/thread.jspa?threadID=737238&tstart=0
I think you might know the answer since it is similar functionality but for text files.
Thanks ! -
Excel 2010 - How to remove leading zero's
I have a column of ID numbers, which looks similar to this:
001
002
010
011
I want to remove all the leading zero's so it looks like this:
1
2
10
11
Can anyone help please?1) Put a value of 1 in a cell (formatted as General)
2) Copy that cell with the value of 1
3) Select the range of values with the leading zeroes
4) Paste > Special > Multiply
Maybe you are looking for
-
Absence Quota In Time Evaluation
Hi, I am working on Absences,i done the configaration part for abxebnce quota and i excute the report RPTQTA00.Its working fine for all Absence QTs. But while i am running the PT60 its displaying only one Absence QT. I need to see the all the Absence
-
How does one access "footers" in Dreamweaver cs6?
How does one access "footers" in Dreamweaver cs6?
-
Is there a way to reference a variable name by the value of a String?
I realize my title may not be expressing the question accurately so... In perl I can do this: $varname = "nIterations"; ${$varname} = 27; which is the same thing as $nIterations = 27; Is there a way to do this in Java? eg I want something like String
-
I made 8 movies. They are all gone!!!!!!!!!! I don't know whether to cry or throw this computer out the window. Is there anything I can do to get my movies back?????? I was able to find the icons for the movies in the Finder. Clicking on them opened
-
Whenever I try to update iTunes, I end up getting this message: http://img.photobucket.com/albums/v329/nariko196/iPodError.jpg I have no idea what this means. Will someone please help me? Windows XP