Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I am generating a word report through c# and open xml but the problem is that when i append altchunk the below code

string id = "ReportChkName" + details.check_id;
string altChunkId1 = id;
AlternativeFormatImportPart altchunk = part.AddAlternativeFormatImportPart(AlternativeFormatImportPartType.Html, altChunkId1);
using (Stream stream = altchunk.GetStream())
{
byte[] buf = (new System.Text.UTF8Encoding()).GetBytes("<html><body>" + mystring + "</body></html>");
stream.Write(buf, 0, buf.Length);
}
AltChunk altChunk1 = new AltChunk();
altChunk1.Id = altChunkId1;
run362.Append(altChunk1);


the chinese text in 'mystring' should not appear on word report in appropriate format.


So will you please help me, how can i append the string with chinese text
Posted

1 solution

Hi...I solved this problem itself by altering the below statement

byte[] buf = (new System.Text.UTF8Encoding()).GetBytes("<html><body>" + mystring + "</body></html>");

the above statement is replace by

byte[] buf = Encoding.Unicode.GetPreamble().Concat(Encoding.Unicode.GetBytes("<html><body>" + mystring + "</body></html>">" + details.check_comments + "</body></html>")).ToArray();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900