从javascript

时间:2017-02-17 06:23:21

标签: javascript excel encoding utf-8 excel-2013

function View_ParamReport() {
   var xmlPathName = inputPath.innerText;
   //Based on the input selcted it selectes the particular xslt code and generates the xml output
   var xml = new ActiveXObject("Msxml2.DOMDocument.6.0");
   xml.async=false;
   xml.load(xmlPathName);
   var xsl = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.6.0");
   xsl.setProperty("AllowDocumentFunction", true); 
   xsl.async=false;
   var xslTemp = new ActiveXObject("Msxml2.XSLTemplate.6.0");
   xslTemp.stylesheet  = xsl;

   var xslProc = xslTemp.createProcessor();
   xslProc.input = xml;                
   try {
       xslProc.transform;
       var report2= xslProc.output;	
       var fso = new ActiveXObject("Scripting.FileSystemObject");
       var filePath = "C:\\Program Files (x86)\\" + orderNumber + ".xls";   	    
       var s = fso.CreateTextFile(filePath, true);    			
       s.WriteLine(report2);
       //If I pass some chinese  character in the  report2 it is                  //getting corrupted.
       //Eg:s.WriteLine("订单编号"); gives ???? in the excel 
       s.Close();
       window.open(filePath);
   } catch(e) {
            
   }

}
我试图使用JavaScript将xsl输出传递给Excel。当输出为英语时,它工作正常。然而,当它是英文和中文的混合时,它正确地显示英文字母但汉字变成了损坏的字符串。我正在使用Excel 2013.我该如何解决这个问题?

0 个答案:

没有答案