2017-04-26 80 views
0

我正在創建一個commonreport,但我使用逗號而不是點來獲取小數值。我試圖改變如下的文化價值,並在我的PDF得到了相同的逗號得到逗號而不是小數點動態CommonReport

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); 

這是我的代碼:

ReportGenerator gen = new ReportGenerator(tbl, dt); 

    ReportDataSource ds = new ReportDataSource(tbl, dt); 
    LocalReport report=new LocalReport(); 
Tuple<System.IO.Stream, float> res = gen.GeneraReport(compName, prm, abbr, font); 
    report.LoadReportDefinition(res.Item1); 

    Byte[] mybytes = report.Render("PDF"); //for exporting to PDF 
    using (FileStream fs = File.Create(fn)) 
    { 
     fs.Write(mybytes, 0, mybytes.Length); 
    } 

    Response.Clear(); 
    Response.Buffer = false; 
    Response.AddHeader("Accept-Ranges", "bytes"); 
    Response.ContentType = "application/octet-stream"; 
    Response.AddHeader("Connection", "Keep-Alive"); 
    Response.ContentEncoding = System.Text.Encoding.UTF8; 
    Response.AppendHeader("Content-Type", "Application/x-pdf"); 
    Response.AppendHeader("Content-disposition", "attachment; filename=" + fileName + ".pdf"); 
    Response.WriteFile(fn); 
    Response.End(); 

我希望它作爲

ColumnName 
1000.0 

在PDF實際輸出是

ColumnName 
1000,0 

thanks in推進

+1

看看[這個答案](http://stackoverflow.com/a/5965748/579895)幫助 – Pikoh

+0

嗨,我試過了。它沒有工作。任何其他鏈接? –

回答

0

我改變

LoadReportDefinition 

屬性更改報告的文化和它的工作。 現在我得到小數,而不是在PDF 逗號我不得不放置一個斷點在「字符串內容」並閱讀其內容,找出文化報表使用

Tuple<System.IO.Stream, float> res = gen.GeneraReport(compName, prm, abbr, font); 
    string content = new StreamReader(res.Item1, Encoding.UTF8).ReadToEnd(); 
    content = content.Replace("<Language>it-IT</Language>", "<Language>en-IN</Language>"); 

    //report.LoadReportDefinition(res.Item1); 
    report.LoadReportDefinition(new MemoryStream(Encoding.UTF8.GetBytes(content))); 

謝謝大家誰幫我 問候

相關問題