Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

how to convert ASCII to Unicode when export to excel(.xls) using Classic asp

$
0
0
Hello All

Iam working on classic asp developer and i am trying to export some record set data to excel , but in that excel contains unicode characters(Chinese) and i am getting error message such as this below

Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument

I am using below method code currently to export excel :
Function OutputOneFile(flCnt, RS, fs)

Dim strFileName, recCnt, OutFile

recCnt = 0
strFileName = Application("OutputPath") & Session("LoginID") & "-" & flCnt & ".xls "

Set OutFile = fs.CreateTextFile(strFileName,True)

For i = 0 To RS.Fields.Count - 1
RowData = RowData & RS(i).Name & vbTab
Next

OutFile.WriteLine(RowData)

Do While ((Not RS.EOF) And (recCnt < 65000))
RowData=""

For i = 0 To RS.Fields.Count - 1
RowData = RowData & RS(i) & vbTab
RowData = replace(RowData,vbCRLF," ")
Next

OutFile.WriteLine(RowData)

RS.MoveNext
recCnt = recCnt + 1
Loop

OutFile.Close
Set OutFile = Nothing

UniqueFileId= "" & DatePart("y",now()) & DatePart("n",now()) & DatePart("s",now()) & ""

Response.Write "Created Excel file: <tr><a href=""/Output/" & Session("LoginID") & "-" & flCnt & ".xls?file=" & UniqueFileID & """ target=_new>" & Session("LoginID") & "-" & flCnt & ".xls&nbsp;&nbsp;</tr></a>"

End Function.

I am getting error on this line of code :

OutFile.WriteLine(RowData)

Let me know anything need to change my code to support excel export to Unicode characters.

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>