我用ActiveReport出力Excel文件,在rpx模板上设置的格式,但出力出来的Excel
文件看起来特别乱,我是直接出力的
this.xlsExport1.Export(rpt.Document,"D:\\Sample.xls");
请问在处理Excel文件的时候对需要做怎样设置,这方面资料很少,才能让生成的Excel文件不乱,还有,哪位兄弟有关于ActiveReport for .net中文帮组文档。急呀!我开始装的是中文版,在开始菜单里看不见,没有帮组文档,现在用的是日文的,看不懂,那位兄弟棒下忙 多谢了!~~~~~~~~

解决方案 »

  1.   

    没用过,直接用的EXCEL写数据
      

  2.   

    公司现在必须要用这个工具,自己写也比较复杂,好像还要一个cell一个cell定义,比较繁琐,哪位大虾有个这方面的开发经验,或者有中文帮组文档,这方面资料太少了,郁闷死了,google翻烂了
      

  3.   

    个人近期开发积累的经验:生成/读取(反向更新数据库) Excel文件:
    http://blog.csdn.net/ChengKing/archive/2005/11/29/539514.aspx
      

  4.   

    兄弟是哪个公司的啊?我们公司也用那鬼东西,看google没用的,还是看它的帮助文档吧,日文的……
      

  5.   

    谢谢楼上 ,我现在用的也是日文版,日文帮组,我是在做调查,刚拿到手没多长时间,关键是EXCEL格式问题,帮组文档上讲的好像也不是太多!楼上能不能将详细点
      

  6.   

    谢谢ChengKing(Enthusiasm Bigrosoft),但我必须要用ActiveReport这个工具~
      

  7.   

    ActiveReport rpt    = null;
    private void rptExcelDownLoad()
    {
    Response.Buffer = true;
    Response.ClearContent();
    Response.ClearHeaders();
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    XlsExport excel = new XlsExport();
    System.IO.MemoryStream m_stream = new System.IO.MemoryStream();
    try
    {
    excel.Export(this.rpt.Document, m_stream);
    int bufSize = (int)m_stream.Length;
    byte[] buf = new byte[bufSize];
    buf = m_stream.ToArray();
    Response.ContentType = "application/octet-stream";
    Response.AddHeader("Content-Disposition", "attachment;filename=MyExport.xls");
    Response.OutputStream.Write(buf, 0, bufSize);
    Response.End();
    }
    finally
    {
    m_stream.Close();
    }
    }
      

  8.   

    private void rptPDFDownLoad()
    { // Tell the browser this is a PDF document so it will use an appropriate viewer.
    // If the report has been exported in a different format, the content-type will 
    // need to be changed as noted in the following table:
    //  ExportType  ContentType
    //    PDF       "application/pdf"  (needs to be in lowercase)
    //    RTF       "application/rtf"
    //    TIFF      "image/tiff"       (will open in separate viewer instead of browser)
    //    HTML      "message/rfc822"   (only applies to compressed HTML pages that includes images)
    //    Excel     "application/vnd.ms-excel"
    //    Excel     "application/excel" (either of these types should work) 
    //    Text      "text/plain"  
    Response.ContentType = "application/pdf";

    // IE & Acrobat seem to require "content-disposition" header being in the response.
    // If you don't add it, the doc still works most of the time, but not always.
    // this makes a new window appear: Response.AddHeader("content-disposition","attachment; filename=MyPDF.PDF");
    Response.AddHeader("content-disposition","inline; filename=MyPDF.PDF"); // Create the PDF export object
    PdfExport pdf = new PdfExport();
    // Create a new memory stream that will hold the pdf output
    System.IO.MemoryStream memStream = new System.IO.MemoryStream();
    // Export the report to PDF:
    pdf.Export(rpt.Document, memStream);
    // Write the PDF stream out
    Response.BinaryWrite(memStream.ToArray());
    // Send all buffered content to the client
    Response.End();
    }private void rptHTMLDownLoad()
    {
    // Buffer this pages output until the report output is ready.
    Response.Buffer = true;
    // Clear any part of this page that might have already been buffered for output.
    Response.ClearContent();
    // Clear any headers that might have already been buffered (such as the content type for an HTML page)
    Response.ClearHeaders();
    // Tell the browser and the "network" that this resulting data of this page should be cached since this could be a dynamic report that changes upon each request.
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    // Tell the browser this is a HTML document so it will use an appropriate viewer.
    Response.ContentType = "text/html"; // Create the HTML export object
    HtmlExport html = new HtmlExport(); // Export the report to HTML in this session's webcache:
    CustomHtmlOutput _output = new CustomHtmlOutput(this.Context); html.Export(rpt.Document, _output, "");

    Response.Redirect("ReportOutput" + "/" +  System.IO.Path.GetFileName(_output.MainPage));
    }
      

  9.   

    还是谢谢楼上的代码,不过我主要是要的是控制出力的EXCEL文件格式,还有,我现在用的是测试版,线条之类出力不出来~
    这是我写的excel处理代码:
    private void Form1_Load(object sender, System.EventArgs e)
    {
        rptExports rpt = new rptExports();
        this.viewer1.Document = rpt.Document;
        rpt.Run(false);    xlsExport1.AutoRowHeight = true;
        xlsExport1.DisplayGridLines = true;
        xlsExport1.FileFormat = DataDynamics.ActiveReports.Export.Xls.FileFormat.Xls97Plus;
        xlsExport1.MinColumnWidth = 360;
        xlsExport1.MinRowHeight = 250;
        xlsExport1.MultiSheet = true;
        xlsExport1.RemoveVerticalSpace = true;
        xlsExport1.UseCellMerging = false;    xlsExport1.Export(rpt.Document, "D:\\x.xls");
    }XlsExport这个控件本身只能设置上面几种属性,我想在向让Excel出力的格式和rpx模板文件一样,而且还能设置Excel边框之类的
    下面是设置Excel属性的:
    private void Form1_Load(object sender, System.EventArgs e)
    {
    DataDynamics.SpreadBuilder.Workbook sb = new DataDynamics.SpreadBuilder.Workbook();
    sb.Sheets.AddNew();
    sb.Sheets[0].Name = "Customer Call List";
    sb.Sheets[0].Columns(0).Width = 2 * 1440;
    sb.Sheets[0].Columns(1).Width = 1440;
    sb.Sheets[0].Columns(2).Width = 1440;
    sb.Sheets[0].Rows(0).Height = 1440/4;
    sb.Sheets[0].Cell(0,0).SetValue("会社名");
    sb.Sheets[0].Cell(0,0).FontName = "MS UI Gothic";
    sb.Sheets[0].Cell(0,0).FontBold = true;
    sb.Sheets[0].Cell(0,1).SetValue("部署名");
    sb.Sheets[0].Cell(0,1).FontName = "MS UI Gothic";
    sb.Sheets[0].Cell(0,1).FontBold = true;
    sb.Sheets[0].Cell(0,2).SetValue("電話番号");
    sb.Sheets[0].Cell(0,2).FontName = "MS UI Gothic";
    sb.Sheets[0].Cell(0,2).FontBold = true;
      sb.Sheets[0].Cell(1,0).SetValue("グレープシティ");
    sb.Sheets[0].Cell(1,0).FontName = "MS UI Gothic";
    sb.Sheets[0].Cell(1,1).SetValue("営業部");
    sb.Sheets[0].Cell(1,1).FontName = "MS UI Gothic";
    sb.Sheets[0].Cell(1,2).SetValue("(022) 777-8210");
    sb.Save (Application.StartupPath + @"\x.xls");
    MessageBox.Show(Application.StartupPath + @"\x.xls" + "へ保存しました。");
    }
    怎样才能保证模板上的那一块出力到Excel哪一块,还有牵扯到跨行等问题,比如说,我在report模板上面一个textbox值,想出力到excel上,我想让它规定处理到那一行哪一列,跨几行,跨几列,等,如何解决~ 
      

  10.   

    下面是日文帮组文档上关于这方面的一些介绍,本人日语有限,有哪位大虾帮我翻译一些 不胜感激,
    XlsExportクラスは、基本的に1つのTextBoxやLabelコントロールを1つのセルへ出力します。これらが、グリッドへ出力した場合に整列するように、コントロールの位置(Top,Left)やサイズ(Height,Width)を調整してください。例えば、あるTextBox上に別のTextBoxが重なって配置されていたり、並べて配置している2つのTextBoxの高さが、一方では「0.488インチ」もう一方では「0.447インチ」などのようにずれがある場合などに、Excel上でセルの位置がずれる可能性があります。このような場合は、TextBox同士が重ならないように配置したり、高さを揃えるなどの調整を行ってください。デザイナ上のコントロールの位置や高さは、「レポートの設定」ダイアログの[グローバル設定]-[ルーラの単位]で設定されたインチやcm単位で表示されますが、実際にRPXファイル内に保存される(レポート生成時に使用される)情報の単位は、Twips単位(1インチ=1440Twips)となります。そのため、「レポート設定」ダイアログ上で「コントロールをグリッドに合わせる」に設定されている状態でコントロールをドラッグした場合など、インチ(cm)からTwips単位への換算が行われる段階で小数点以下の誤差が発生することがあります。その結果、プロパティウィンドウ上で同じ高さに設定されているコントロールでも、RPXファイルに実際に記述されている高さが異なってしまい、結果的にExcel上でのセル位置や高さに影響を与えてしまう可能性があります。プロパティウィンドウ上でコントロールを同じ高さに設定しているにもかかわらず、Excelエクスポート時にセルの高さがずれるという場合は、コントロールの位置やサイズを一旦別の値に設定した上で、再度統一して設定し直すか、RPXファイル内の記述をテキストエディタで直接編集してください。