Wednesday, March 7, 2012

ReportingService.Render(CSV)

I am calling a reporting service proxy's Render Method passing "CSV" as the format.
Dim result As Byte() = ReportingService.Render("/SomeRPT", "CSV", ...)
Return Text.Encoding.Unicode.GetString(result)
This returns a unicode byte array. This array has four leading bytes (255,254,83,0) that do not belong in the output. If I use the GetString method all of the null chars are stripped out, but this leaves three leading bytes (255,254,83) that do not exist if I call the same report from a web page, and then save as CSV. If I render this report with html, excel, or pdf as a format, the output is as expected.

Is this a bug in the SQL Report Services, Web Service?
Or am I doing something wrong?

Regards,
Ken

Check out MimeType of the result, is it UTF-8? 0xFF and 0xFE are Unicode byte order marks. Save your byte array to a file on disk and open it in the notepad, you shouldn't see any unexpected characters. Alternatively, open StreamReader on it, I think StreamReader recognizes byte order marks.

No comments:

Post a Comment