Home » Developer & Programmer » Reports & Discoverer » Problem While Creating Excel (because of CHR(44))
Problem While Creating Excel (because of CHR(44)) [message #478079] Wed, 06 October 2010 01:59 Go to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

[Topics merged by LF, as it appears that both discuss the same problem.]


Hello I creating a report in excel format...
But there is one problem which i shown in colour when excel created.... i dont know why this problem come..
Here i m attched my .fmb file and excel sheet [When i run my form].....

please let me know why this problem comes????

My Code is :
When Excel Button pressed

PROCEDURE EXCEL_P IS

cursor c1 is
select distinct BPT_DOC_DT BNP_REF_DT, BPT_DOC_NO BNP_REF_NO,
BPT_VEN_NM Vendor_Name,
BPT_BIL_NO Bill_No, BPT_BIL_DT Bill_Date ,
BPT_CNTRCT_CD CONTRACT_NO,
BPT_NET_VOU Total_Amount,
DECODE(BPT_BAS_RT, NULL, BPT_BIL_RT, BPT_BAS_RT) Basic_Amt,
BPT_SAL_RT VAT_AMOUNT,
BPT_SAL_CLU VAT_Rate ,
B.VMT_VAT_NO vendor_tin_no,
(B.VMT_VNDR_ADDR1 ||','|| B.VMT_VNDR_ADDR2||','||VMT_VNDR_ADDR3 ||','|| B.VMT_VNDR_ADDR4 ||','|| B.VMT_VNDR_ADDR5)
Vendor_address
FROM BILL_HDR1_TAB , VNDR_MST1_TAB B
WHERE BPT_LOC = :BLK_ENTER.LOC
AND BPT_VEN_CD = B.VMT_VNDR_CD
AND TO_DATE(BPT_DOC_DT, 'DD-MON-RRRR') > TO_DATE('01-apr-'||:BLK_ENTER.FYYEAR,'DD-MON-RRRR')
AND TO_DATE(BPT_BIL_DT, 'DD-MON-RRRR') <= TO_DATE('31-MAR-'||:BLK_ENTER.FYYEAR,'DD-MON-RRRR')
order by BPT_doc_DT ;

FILE_PTR CLIENT_TEXT_IO.FILE_TYPE;-------capture only text data
tot number := 0;

begin

FILE_PTR:= CLIENT_TEXT_IO.FOPEN(:FILENAME,'w');---w window , chr(44)-Delimeter comma separated
CLIENT_TEXT_IO.NEW_LINE(FILE_PTR);------space


client_text_io.put_line(file_ptr,'Location: '||:BLK_ENTER.LOC);
client_text_io.new_line(file_ptr);
client_text_io.put_line(file_ptr,'Financial Year is '||:BLK_ENTER.FYYEAR);
client_text_io.new_line(file_ptr);
client_text_io.put_line(file_ptr,'BNP REF DATE'||CHR(44)||'BNP REF NO.'||CHR(44)||'VENDOR NAME'||CHR(44)||'BILL NO'||CHR(44)||'BILL DATE'||CHR(44)||'CONTRACT NO'||CHR(44)||'TOT AMOUNT'||CHR(44)||'BASIC AMT'||CHR(44)||'VAT AMT'||CHR(44)||'VAT RATE'||CHR(44)||'VENDOR TIN NO'||CHR(44)||'VENDOR ADDRESS');
client_text_io.new_line(file_ptr);

-- message('4');
FOR I IN c1
LOOP
EXIT WHEN c1%NOTFOUND;
-- synchronize;
CLIENT_TEXT_IO.PUT_LINE(FILE_PTR,I.BNP_REF_DT||chr(44)||I.BNP_REF_NO||chr(44)||I.Vendor_Name||chr(44)||I.Bill_No||chr(44)||I.Bill_Dat e||CHR(44)||I.CONTRACT_NO||CHR(44)||I.Total_Amount||CHR(44)||I.Basic_Amt||CHR(44)||I.VAT_AMOUNT||CHR(44)||I.VAT_Rate||CHR(44)||I.vend or_tin_no||CHR(44)||REPLACE(I.Vendor_address,',',' '));
tot := tot + 1 ;
synchronize;
END LOOP ;
client_text_io.new_line(file_ptr);
client_text_io.put_line(file_ptr,' '||chr(44)||'Total No. of Bill Booked ' || chr(44)||tot);
IF c1%ISOPEN THEN
CLOSE c1;
END IF;
synchronize;
CLIENT_TEXT_IO.FCLOSE(FILE_PTR);
message(' The File'||:FILENAME||'has been generated successfully');

END;

  • Attachment: swapnil2.csv
    (Size: 14.74KB, Downloaded 1620 times)

[Updated on: Fri, 08 October 2010 03:11] by Moderator

Report message to a moderator

Re: Problem While Creating Excel [message #478102 is a reply to message #478079] Wed, 06 October 2010 04:48 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

If Any other information required please let me know
Re: Problem While Creating Excel [message #478108 is a reply to message #478102] Wed, 06 October 2010 05:34 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
A discription of what the actual problem is would be a good start. colour coding doesn't work in csv files.
Also can you please read and follow the orafaq forum guide, especially the section on how to format your post.
Re: Problem While Creating Excel [message #478119 is a reply to message #478079] Wed, 06 October 2010 07:15 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

i m creating report which is in excel format, when usert press excel button in form..

My all data correctly put in excel except one row which i coloured in excel...

I am also posting code which i written on button -trigger...

Is anything i missing so data is not correctly captured in excel..which i have to understand ???
Re: Problem While Creating Excel [message #478124 is a reply to message #478119] Wed, 06 October 2010 07:30 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Download the csv file you attached.
Open it in excel.
Can you see any colour coding?
Re: Problem While Creating Excel [message #478204 is a reply to message #478079] Thu, 07 October 2010 01:28 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

Now i send file in pdf format....because while saving in csv format..whatever chages did lost....
  • Attachment: swapnil2.pdf
    (Size: 64.46KB, Downloaded 2329 times)
Re: Problem While Creating Excel [message #478205 is a reply to message #478204] Thu, 07 October 2010 01:58 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Best guess - the vendor_name on the line before has a carriage return or other special character in it that's causing the problem.
Use the dump funciton to find out what's actually in there.
Re: Problem While Creating Excel [message #478206 is a reply to message #478205] Thu, 07 October 2010 02:14 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

THANKS....I send mt .fmb file to you...can u shown me how to use Dump function find special character
Re: Problem While Creating Excel [message #478208 is a reply to message #478206] Thu, 07 October 2010 02:31 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
dump

The fmb isn't going to be much use here. Just select the dump of that column from the DB in sqlplus and see what's in it. You're looking for characters with an ascii value of 31 or less or 127 or greater.
carriage return is 13. You can see all the ascii values here

EDIT: typos

[Updated on: Thu, 07 October 2010 02:32]

Report message to a moderator

Re: Problem While Creating Excel [message #478214 is a reply to message #478208] Thu, 07 October 2010 03:40 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

That means may i use CHR(31) insted of CHR(44)...

I Use dump for thsi record i get following result for vendor name

11 5/13/2009 1090100121 TRAVEL CORPORATION (INDIA) LTD.
33/412/00225 Typ=1 Len=31: 84,82,65,86,69,76,32,67,79,82,80,79,82,65,84,73,79,78,32,40,73,78,68,73,65,41,32,76,84,68,46
Re: Problem While Creating Excel [message #478215 is a reply to message #478214] Thu, 07 October 2010 04:15 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
I doubt you want to use CHR(31) not sure what it does. I'd stick with ch4(44) personally.
I can't see anything obvious in the dump output either.
You're just going to have to debug this.
Limit the query to just retrieve the one record we're looking at and see if it gets split over two lines.
If it does output the line to a text item in the form rather than write it to a file so you can see what is in it.
If necessary remove columns to isolate which one is causing the problem.
Re: Problem While Creating Excel [message #478216 is a reply to message #478215] Thu, 07 October 2010 04:24 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
It might also help if you wrap each item in double quotes as well.
So
||CHR(44)||
would become
||'","'||

Re: Problem While Creating Excel [message #478218 is a reply to message #478216] Thu, 07 October 2010 04:46 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

As per your suggestion , i check this code for sing le line wheer i stuck ..
i get rsult..
1 5/13/2009 1090100121 TRAVEL CORPORATION (INDIA) LTD.
Typ=1 Len=32: 84,82,65,86,69,76,32,67,79,82,80,79,82,65,84,73,79,78,32,40,73,78,68,73,65,41,32,76,84,68,46,10 33/412/00225 Typ=1 Len=12: 51,51,47,52,49,50,47,48,48,50,50,53 3/12/2009 1465.00 1465 65-PURCHASE FORM TAX FREE 999 CHANDER MUKHI, 1ST FLOOR,,NARIMAN POINT, MUMBAI - 400 021.,,,


Bold line ascii value define new line ..

How to suppress this value from my data...is any function used for this field...so i replace this value...
Re: Problem While Creating Excel [message #478220 is a reply to message #478218] Thu, 07 October 2010 05:07 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Use replace and chr functions to remove it.
Re: Problem While Creating Excel [message #478222 is a reply to message #478220] Thu, 07 October 2010 05:29 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

So i can write this Replace(Field name ,',', ' ')
But how to replace ascii value in field..
Re: Problem While Creating Excel [message #478223 is a reply to message #478222] Thu, 07 October 2010 05:36 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

Thanks Cookie,

Finally My problem solved with your help...i use Replace(Field name, CHR(10), ' ')
Excel Convesion Pblm Because of chr(44) [message #478234 is a reply to message #478079] Thu, 07 October 2010 06:14 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

There is one example where i taken dump of that field...
I get result this way

My Query is like this

select distinct BPT_DOC_DT BNP_REF_DT, BPT_DOC_NO BNP_REF_NO,
BPT_VEN_NM Vendor_Name,
replace(BPT_BIL_NO,',','.') Bill_No,dump( BPT_BIL_NO), BPT_BIL_DT Bill_Date ,
BPT_CNTRCT_CD CONTRACT_NO,
BPT_NET_VOU Total_Amount,
DECODE(BPT_BAS_RT, NULL, BPT_BIL_RT, BPT_BAS_RT) Basic_Amt,
BPT_SAL_RT VAT_AMOUNT,
BPT_SAL_CLU VAT_Rate ,
B.VMT_VAT_NO vendor_tin_no,
(B.VMT_VNDR_ADDR1 ||','|| B.VMT_VNDR_ADDR2||','||VMT_VNDR_ADDR3 ||','|| B.VMT_VNDR_ADDR4 ||','|| B.VMT_VNDR_ADDR5)
Vendor_address
FROM BILL_HDR1_TAB , VNDR_MST1_TAB B
WHERE BPT_LOC = '01'
AND BPT_VEN_CD = B.VMT_VNDR_CD
AND TO_DATE(BPT_DOC_DT, 'DD-MON-RRRR') > TO_DATE('01-apr-'||2009,'DD-MON-RRRR')
AND TO_DATE(BPT_BIL_DT, 'DD-MON-RRRR') <= TO_DATE('31-MAR-'||2009,'DD-MON-RRRR')
AND BPT_DOC_NO = '1090100097'
order by BPT_doc_DT


I only show output that bold bold line
O/P Like this

BILL_NO DUMP(BPT_BIL_NO)
MAR.,09 Typ=1 Len=7: 77,65,82,46,44,48,57

Because of 44 in Dump(BPT_BIL_NO)...My Excel convesrion somehow wrong...how to replace this code....
Re: Excel Convesion Pblm Because of chr(44) [message #478242 is a reply to message #478234] Thu, 07 October 2010 07:28 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
As I said in your other thread - wrap each column in double-quotes. excel will not treat commas as delimiters if they're wrapped in double quotes.
Re: Excel Convesion Pblm Because of chr(44) [message #478243 is a reply to message #478242] Thu, 07 October 2010 07:38 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

thanks you

[Updated on: Thu, 07 October 2010 07:39]

Report message to a moderator

Re: Excel Convesion Pblm Because of chr(44) [message #478336 is a reply to message #478243] Thu, 07 October 2010 23:24 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

hi Cookie..
if i wrap each column in double qotes...i get compile error...define those field as a variable
Re: Excel Convesion Pblm Because of chr(44) [message #478337 is a reply to message #478336] Thu, 07 October 2010 23:30 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

I did as you say..but
still geeting a problem for one row only..

cursor c1 is
select distinct "BPT_DOC_DT" BNP_REF_DT, "BPT_DOC_NO" BNP_REF_NO,
"BPT_VEN_NM" Vendor_Name,
"BPT_BIL_NO" Bill_No, "BPT_BIL_DT" Bill_Date ,
"BPT_CNTRCT_CD" CONTRACT_NO,
"BPT_NET_VOU" Total_Amount,
DECODE(BPT_BAS_RT, NULL, BPT_BIL_RT, BPT_BAS_RT) Basic_Amt,
"BPT_SAL_RT" VAT_AMOUNT,
"BPT_SAL_CLU" VAT_Rate ,
B.VMT_VAT_NO vendor_tin_no,
(B.VMT_VNDR_ADDR1 ||','|| B.VMT_VNDR_ADDR2||','||VMT_VNDR_ADDR3 ||','|| B.VMT_VNDR_ADDR4 ||','|| B.VMT_VNDR_ADDR5)
Vendor_address
FROM BILL_HDR1_TAB , VNDR_MST1_TAB B
WHERE BPT_LOC = :BLK_ENTER.LOC
AND BPT_VEN_CD = B.VMT_VNDR_CD
AND TO_DATE(BPT_DOC_DT, 'DD-MON-RRRR') > TO_DATE('01-apr-'||:BLK_ENTER.FYYEAR,'DD-MON-RRRR')
AND TO_DATE(BPT_BIL_DT, 'DD-MON-RRRR') <= TO_DATE('31-MAR-'||:BLK_ENTER.FYYEAR,'DD-MON-RRRR')
-- AND BPT_DOC_NO = '1090100121'
order by BPT_doc_DT
;
Re: Excel Convesion Pblm Because of chr(44) [message #478342 is a reply to message #478337] Fri, 08 October 2010 01:58 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
That's not going to put double-quotes in the file output is it?
I gave an example of what you need to do in the other thread.
Re: Excel Convesion Pblm Because of chr(44) [message #478343 is a reply to message #478342] Fri, 08 October 2010 02:16 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

i did this well also...but when i get error message like declare a variable

What i did i shown here, if wrong correct me

Header Line for excel

client_text_io.put_line(file_ptr,'BNP REF DATE'||CHR(44)||'BNP REF NO.'||CHR(44)||'VENDOR NAME'


Detail for excel

CLIENT_TEXT_IO.PUT_LINE(FILE_PTR,"I.BNP_REF_DT"||CHR(44)||"I.BNP_REF_NO"||CHR(44)||REPLACE("I.Vendor_Name",chr(10),' '))

if i wrong may i know where i put " "...
Re: Excel Convesion Pblm Because of chr(44) [message #478358 is a reply to message #478343] Fri, 08 October 2010 03:40 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Scroll up to my example.
Read it.
Compare it to what you've done.
Correct what you've done so that it actually looks like what I said.

And will you please start using [code] tags. I've asked you to do this already.
Re: Excel Convesion Pblm Because of chr(44) [message #478378 is a reply to message #478358] Fri, 08 October 2010 06:36 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

If i follow as u told me
' "chr(44)" '
All records stors only on one excel row....
Re: Excel Convesion Pblm Because of chr(44) [message #478382 is a reply to message #478378] Fri, 08 October 2010 06:52 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Have you put a " at the begining and end of each line? Looks like so far you've only put the " between the columns.
Re: Excel Convesion Pblm Because of chr(44) [message #478383 is a reply to message #478382] Fri, 08 October 2010 06:53 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
And also why don't you try debugging this?
Print the line to screen.
See where the " are.
Amend the code until they're in the right places.
Previous Topic: Running rwrun.sh creates Memory fault on Redhat Linux
Next Topic: footer in layout in main section
Goto Forum:
  


Current Time: Thu Apr 25 17:37:38 CDT 2024