Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
732 views
in Technique[技术] by (71.8m points)

c# - How to activate specific worksheet in Excel by exporting /w FastReport

I create a report using FastReport in which there are 2 ReportPage

ReportPages

This report is exported to Excel format and when I open Excel, these 2 sheets are selected at the same time

2sheets Below is attached a snippet of code with which I generate a report. The question is, how do i active the one specific sheet?

        private static byte[] CreateReport(Stream fastReportTemplateStream, DataSet ds, RepType repType, Dictionary<string, object> parameters = null)
    {
        FastReport.Utils.Config.WebMode = true;

        using (Report report = new Report())
        {
            report.Load(fastReportTemplateStream);
            report.RegisterData(ds);
            if (parameters != null)
                foreach (var prm in parameters)
                    report.SetParameterValue(prm.Key, prm.Value);
            report.Prepare();

            return CreateReport(report, repType);
        }
    }

    public static byte[] CreateReport(Report report, RepType repType)
    {
        using (MemoryStream mem_str = new MemoryStream())
        {
            switch (repType)
            {
                case RepType.XLSX:
                    report.Export(new FastReport.Export.OoXML.Excel2007Export(), mem_str);
                    break;
                case RepType.PDF:
                    report.Export(new FastReport.Export.Pdf.PDFExport(), mem_str);
                    break;
            }

            return mem_str.ToArray();
        }
        throw new Exception();
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...