当前位置: 首页>>代码示例>>C#>>正文


C# XlsFile.Save方法代码示例

本文整理汇总了C#中XlsFile.Save方法的典型用法代码示例。如果您正苦于以下问题:C# XlsFile.Save方法的具体用法?C# XlsFile.Save怎么用?C# XlsFile.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XlsFile的用法示例。


在下文中一共展示了XlsFile.Save方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Export

        /// <summary>
        /// 
        /// </summary>
        internal override void Export()
        {
            _xls = new XlsFile();
            //_xls.Open(_xlsPath);
            _xls.NewFile (1);

            SetCellValue(_xls, Config.TitleArea,
                string.Format(ReportStrings.Title, B, E), false);
            MergeCells(_xls, Config.TitleArea);

            // set first column names
            //

            int row = ExportFirst(5);
            ExportStations(row);

            string filename = Xdgk.Common.Path.GetTempFileName("xls");
            _xls.Save(filename);
            Open(filename);
        }
开发者ID:hkiaipc,项目名称:fnq,代码行数:23,代码来源:XfDayReportExporter.cs

示例2: WriteSerializationResult

        public void WriteSerializationResult( Stream stream )
        {
            XlsFile xlsFile = new XlsFile(true);
            DataTableCollection tables = ResultDataSet.Tables;

            // создать новый XLS-файл
            xlsFile.NewFile( tables.Count );

            // записать в файл содержимое каждой таблицы
            for (int tableIndex = 0; tableIndex < tables.Count; ++tableIndex)
            {
                // установить текущий лист
                xlsFile.ActiveSheet = tableIndex + 1;
                WriteDataTable( tables[tableIndex], xlsFile );
            }

            // отправить содержимое файла в поток
            xlsFile.Save( stream );

            // сбросить вспомогательный DataSet
            ResultDataSet.Tables.Clear();
        }
开发者ID:Confirmit,项目名称:Portal,代码行数:22,代码来源:ExcelSerializer.cs

示例3: CreateSpreadsheet

        void CreateSpreadsheet()
        {
            var locations = LocationHelper.Instance.Locations;

            var xls = new XlsFile (1, true);
            xls.SetCellValue (1, 1, "Location data from Xamarin.iOS");
            xls.SetCellValue (2, 1, "Latitude");
            xls.SetCellValue (2, 2, "Longitude");
            xls.SetCellValue (2, 3, "Altitude");
            int row = 2;

            xls.MergeCells(1, 1, 1, 3);

            SetTitleCellFormat (xls);

            locations.ForEach (l => {
                xls.SetCellValue (++row, 1, l.Coordinate.Latitude);
                xls.SetCellValue (row, 2, l.Coordinate.Longitude);
                xls.SetCellValue (row, 3, l.Altitude);
            });

            xls.Save (path);
        }
开发者ID:dhinesh886,项目名称:FlexCelDemo,代码行数:23,代码来源:FlexCellDemoViewController.cs

示例4: Export

        internal void Export(GroupResultCollection grs)
        {
            _grs = grs;

            string file = Path.GetTempFileName("xls");
            XlsFile xls = new XlsFile();
            xls.NewFile(GetPersonCount());

            int n = 0;
            foreach (GroupResult gr in grs)
            {
                foreach (PersonResult pr in gr.PersonResults)
                {
                    n++;
                    xls.ActiveSheet = n;
                    xls.SheetName = GetSheetName(gr, pr);
                    DataTable tbl = ResultDataTableConverter.ToPersonResultDataTable(pr);
                    Write(xls, tbl, pr.CalcSumOfWorkTimeSpan());
                }
            }
            xls.Save(file);

            Open(file);
        }
开发者ID:hkiaipc,项目名称:fnq,代码行数:24,代码来源:frmKResultGenerate.cs

示例5: E_ExportData_ToExcel


//.........这里部分代码省略.........
                    bolleto.SetCellValue(iRowCnt, 3, item.Unit_Code);
                    bolleto.SetCellValue(iRowCnt, 4, item.Unit_Price);
                    bolleto.SetCellValue(iRowCnt, 5, item.calculated_Tariff);
                    bolleto.SetCellValue(iRowCnt, 6, item.Base_Taxation);
                    bolleto.SetCellValue(iRowCnt, 7, item.Total);
                    iRowCnt = iRowCnt + 2;
                    x = "A" + iRowCnt;
                    y = "G" + iRowCnt;
                    //xlWorkSheetToExport.Range[x, y].Font.Size = 11;
                    //xlWorkSheetToExport.Range[x, y].Font.Bold = true;

                    bolleto.SetCellValue(iRowCnt, 2, "Levy Name", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 3, "Levy Type", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 4, "Levy", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 5, "Actual Levy", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 6, "Total Levy", titleFormat);
                    bolleto.SetCellValue(iRowCnt, 7, "");
                    //bolleto.SetCellFormat(iRowCnt, 1, iRowCnt, 7, 1);
                    iRowCnt = iRowCnt + 1;
                    for (var l = 0; l < display2.Count(); l++)
                    {
                        if (l == 0 && j != 0)
                        {
                            l = j;
                        }
                        if (item.Goods_Id != display2[l].Goods_Id)
                        {
                            break;
                        }
                        j++;
                        if (display2[l].Levy_Name == "Total")
                        {
                            bolleto.SetCellValue(iRowCnt, 2, display2[l].Levy_Name, titleFormat);
                            bolleto.SetCellValue(iRowCnt, 3, display2[l].Levy_Type, titleFormat);
                            bolleto.SetCellValue(iRowCnt, 4, display2[l].Levy, titleFormat);
                            //bolleto.SetCellValue(iRowCnt, 4).HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                            bolleto.SetCellValue(iRowCnt, 5, display2[l].Actua_Levy, Formatright);
                            bolleto.SetCellValue(iRowCnt, 6, display2[l].Total_Levi, Formatright);
                            bolleto.SetCellValue(iRowCnt, 7, display2[l].Sum_Levies, Formatright);
                            //bolleto.SetCellFormat(iRowCnt, 1, iRowCnt, 7, 1);
                            iRowCnt = iRowCnt + 1;
                        }
                        else
                        {
                            bolleto.SetCellValue(iRowCnt, 2, display2[l].Levy_Name);
                            bolleto.SetCellValue(iRowCnt, 3, display2[l].Levy_Type);
                            bolleto.SetCellValue(iRowCnt, 4, display2[l].Levy);
                            //bolleto.SetCellValue(iRowCnt, 4).HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignRight;
                            bolleto.SetCellValue(iRowCnt, 5, display2[l].Actua_Levy);
                            bolleto.SetCellValue(iRowCnt, 6, display2[l].Total_Levi);
                            bolleto.SetCellValue(iRowCnt, 7, display2[l].Sum_Levies);
                            iRowCnt = iRowCnt + 1;
                        }
                    }
                    iRowCnt = iRowCnt + 1;
                }

                var get_payment_config = db.E_Calculated_Payment_Config.Where(cpc => cpc.way_bill_id == way_bill_id).ToList();
                foreach (var item in get_payment_config)
                {
                    TempData["sos_amount"] = item.calculated_sos_amount;
                    TempData["usd_amount"] = item.calculated_usd_amount;
                    TempData["sos"] = item.calculated_sos_part;
                    TempData["usd"] = item.calculated_usd_part;
                }

                iRowCnt = iRowCnt + 3;

                bolleto.SetCellValue(iRowCnt, 4, "USD Amount (" + TempData["usd"] + "%)", titleFormat);
                bolleto.SetCellValue(iRowCnt, 5, TempData["usd_amount"], titleFormat);

                iRowCnt++;

                bolleto.SetCellValue(iRowCnt, 4, "SOS Amount (" + TempData["sos"] + "%)", titleFormat);
                bolleto.SetCellValue(iRowCnt, 5, TempData["sos_amount"], titleFormat);

                iRowCnt++;

                bolleto.SetCellValue(iRowCnt,7,"Date : " + DateTime.Now.ToString("yyyy-MM-dd"));

                iRowCnt++;

                bolleto.SetCellValue(iRowCnt, 7, "User : " + Session["user_name"].ToString());

                var save_name = "Bolleto_Dogonale_Export_" + bolleto_code + ".xlsx";

                // SAVE THE FILE IN A FOLDER.
                //bolleto.Save(Path.Combine(Server.MapPath("~/App_Data"), copy_file_name));
                bolleto.Save(copy_file_path);

                this.DownLoadFile_Export(save_name, copy_file_path);

                return RedirectToAction("Index");

            }
            else
            {
                return RedirectToAction("../Home");
            }
        }
开发者ID:BTEEMRIYAS,项目名称:TestProject,代码行数:101,代码来源:HomeController.cs

示例6: Report_2


//.........这里部分代码省略.........
            {
                if (daily_trans_Export != null)
                dtExport = LinqQueryToDataTable(daily_trans_Export.ToList());

                if (dtExport.Rows.Count <= 1)
                    goto skipExport;

            }
            catch
            { goto skipExport; }

            //transposing for excel
            DataTable dtTranspose2 = GenerateTransposedTable(dtExport);

            //printing rows
             i = 7;

             color1 = 0;
             color2 = 0;
             color3 = 0;
             color4 = 0;

             datarow = 7;
            foreach (DataRow dr in dtTranspose2.Rows)
            {

                if (dr[1].ToString().Length > 0)
                {
                    if (i % 2 != 0)
                    {
                        color1 = nocolorleft;
                        color2 = nocolor;
                        color3 = nocolorright;
                        color4 = nocolorbold;

                    }
                    else
                    {
                        color1 = leftborder;
                        color2 = coloronly;
                        color3 = rightborder;
                        color4 = colorbold;

                    }

                    report_2.SetCellValue(i, 1 + c, dr[1].ToString().TrimEnd(']').TrimStart('['), color1);
                    report_2.SetCellValue(i, 2 + c, GetDecimal(dr[2].ToString()), color2);
                    report_2.SetCellValue(i, 3 + c, GetDecimal(dr[3].ToString()), color2);
                    report_2.SetCellValue(i, 4 + c, GetDecimal(dr[4].ToString()), color4);
                    report_2.SetCellValue(i, 5 + c, GetDecimal(dr[5].ToString()), color3);
                    datarow++;
                }
                i++;

            }

            laststyle = TopBorderOnly(report_2, i, 1 + c);
            //last line border
            report_2.SetCellValue(datarow, 1 + c, "", laststyle);
            report_2.SetCellValue(datarow, 2 + c, "", laststyle);
            report_2.SetCellValue(datarow, 3 + c, "", laststyle);
            report_2.SetCellValue(datarow, 4 + c, "", laststyle);
            report_2.SetCellValue(datarow, 5 + c, "", laststyle);

            //doing the rest if data is null
            skipExport:

            report_2.PrintToFit = true;
            report_2.PrintPaperSize = TPaperSize.A4;

            TWorkbookProtectionOptions protoptions = new TWorkbookProtectionOptions();
            protoptions.Window = false;
            protoptions.Structure = false;

            TSharedWorkbookProtectionOptions op = new TSharedWorkbookProtectionOptions();
            op.SharingWithTrackChanges = false;

            report_2.Protection.SetSharedWorkbookProtection("XXXX", op);

            report_2.Protection.SetWorkbookProtection("XXXX", protoptions);
            report_2.Protection.SetModifyPassword("XXXX", true, "XXXXXX");
            report_2.Protection.SetWorkbookProtectionOptions(protoptions);

            if (dtImport.Rows.Count <= 1)
                TempData["Warning"] = "No Data To Export";
            else
            {
                report_2.Save(copy_file_path);

                if (typ.Equals("pdf"))
                    GeneratePDF(report_2, "Report_2_"+filterType);

                else
                {
                    Response.AppendHeader("Content-Disposition", "attachment; filename=Report_2_"+filterType+".xlsx");
                    Response.TransmitFile(copy_file_path);
                    Response.End();
                }
            }
        }
开发者ID:BTEEMRIYAS,项目名称:TestProject,代码行数:101,代码来源:ReportController.cs

示例7: Report_1


//.........这里部分代码省略.........
            //get import data
            var daily_trans_import = db.Report_1_Import(Report_date);

            //get import data count
            var daily_trans_import_count = db.Report_1_Import(Report_date).Count();

            //skip if no data
            if (daily_trans_import_count <= 0)
                goto skipImport;

            //print
            int i = 6;

            report_1.SetCellValue(3, 4, exchangerate);

            report_1.SetCellValue(2, 2, Report_date.ToString("dd/MM/yyyy"));

            foreach (var item in daily_trans_import)
            {

                report_1.SetCellValue(i, 2, item.BY_CASH_CHEQUE);
                report_1.SetCellValue(i, 3, item.USD);
                report_1.SetCellValue(i, 4, item.SOS);
                report_1.SetCellValue(i, 5, item.TOTAL_USD);
                report_1.SetCellValue(i, 6, item.TOTAL_SOS);
                i++;
            }

            //skiped import
            skipImport:

            //get export dtaa
            var daily_trans_export = db.Report_1_Export(Report_date);

            //get export count
            var daily_trans_export_count = db.Report_1_Export(Report_date).Count();

            //skip export if no data
            if (daily_trans_export_count <= 0)
                goto skipExport;

            //print export
            i = 14;

            foreach (var item in daily_trans_export)
            {

                report_1.SetCellValue(i, 2, item.BY_CASH_CHEQUE);
                report_1.SetCellValue(i, 3, item.USD);
                report_1.SetCellValue(i, 4, item.SOS);
                report_1.SetCellValue(i, 5, item.TOTAL_USD);
                report_1.SetCellValue(i, 6, item.TOTAL_SOS);
                i++;
            }

            //skipped export
            skipExport:

            //if no import and export return alert msg
            if (daily_trans_import_count <= 0 && daily_trans_export_count <= 0)
            {
                TempData["Warning"] = "No Data To Export";
                return;
            }
            else
            {

                //else print

                report_1.PrintToFit = true;
                report_1.PrintPaperSize = TPaperSize.A4;

                TWorkbookProtectionOptions protoptions = new TWorkbookProtectionOptions();
                protoptions.Window = false;
                protoptions.Structure = false;
                TSharedWorkbookProtectionOptions op = new TSharedWorkbookProtectionOptions();
                op.SharingWithTrackChanges = false;

                report_1.Protection.SetSharedWorkbookProtection("XXXX", op);

                report_1.Protection.SetWorkbookProtection("XXXX", protoptions);
                report_1.Protection.SetModifyPassword("XXXX", true, "XXXXXX");
                report_1.Protection.SetWorkbookProtectionOptions(protoptions);

                string dte = Report_date.ToString("dd/MMM/yyyy");
                dte = dte.Replace("/", "_");
                report_1.Save(copy_file_path);

                if (typ.Equals("pdf"))
                    GeneratePDF(report_1, "Report_1_" + dte);

                else
                {
                    Response.AppendHeader("Content-Disposition", "attachment; filename=Report_1_" + dte + ".xlsx");
                    Response.TransmitFile(copy_file_path);
                    Response.End();
                }

            }
        }
开发者ID:BTEEMRIYAS,项目名称:TestProject,代码行数:101,代码来源:ReportController.cs

示例8: Report_4


//.........这里部分代码省略.........
                if (dtImport.Rows.Count <= 1)
                    goto skip_Import;

            }
            catch
            { goto skip_Import; }

               int i = 12;
            int s = 1;
            c = 2;
            int datarow = 12;
            foreach (DataRow dr in dtImport.Rows)
            {

                if (dr[1].ToString().Length > 0)
                {

                    report_4.SetCellValue(i, 1 + c, s, tformat_col1);
                    report_4.SetCellValue(i, 2 + c, dr[3].ToString(), tformat_col2);
                    report_4.SetCellValue(i, 3 + c, dr[4].ToString(), tformat_col3);
                    report_4.SetCellValue(i, 4 + c, dr[5].ToString(), tformat_col4);
                    report_4.SetCellValue(i, 5 + c, GetDecimal(dr[1].ToString()), tformat_col5);
                    report_4.SetCellValue(i, 6 + c, GetDecimal(dr[2].ToString()), tformat_col6);
                    datarow++;
                }
                i++;
                s++;

            }

            skip_Import:

            Header = "Daily Bolleto Dogonale Report     :" + filterType;

            DataTable dtexport = new DataTable();

            //get export dtaa

            report_4.ActiveSheet = 2;

            report_4.SetCellValue(10, 3, Header, tformat_head);

            //skip export if no data
            try
            {
                if (daily_trans_Export != null)
                    dtexport = LinqQueryToDataTable(daily_trans_Export.ToList());

                if (dtexport.Rows.Count <= 1)
                    goto skipExport;

            }
            catch
            { goto skipExport; }

            //print export
            i = 12;
            s = 1;

            datarow = 12;
            foreach (DataRow dr in dtexport.Rows)
            {

                if (dr[1].ToString().Length > 0)
                {

                    report_4.SetCellValue(i, 1 + c, s, tformat_col1);
                    report_4.SetCellValue(i, 2 + c, dr[3].ToString(), tformat_col2);
                    report_4.SetCellValue(i, 3 + c, dr[4].ToString(), tformat_col3);
                    report_4.SetCellValue(i, 4 + c, dr[5].ToString(), tformat_col4);
                    report_4.SetCellValue(i, 5 + c, GetDecimal(dr[1].ToString()), tformat_col5);
                    report_4.SetCellValue(i, 6 + c, GetDecimal(dr[2].ToString()), tformat_col6);

                    datarow++;
                }
                i++;
                s++;
            }

              //doing the rest if data is null
            skipExport:

            //if no import and export return alert msg
            if (dtImport.Rows.Count <= 1)
                TempData["Warning"] = "No Data To Export";
            else
            {
                report_4.Save(copy_file_path);

                if (typ.Equals("pdf"))
                    GeneratePDF(report_4, "Report_4_"+filterType);

                else
                {
                    Response.AppendHeader("Content-Disposition", "attachment; filename=Report_4_"+filterType+".xlsx");
                    Response.TransmitFile(copy_file_path);
                    Response.End();
                }
            }
        }
开发者ID:BTEEMRIYAS,项目名称:TestProject,代码行数:101,代码来源:ReportController.cs

示例9: Report_3


//.........这里部分代码省略.........
            report_3.SetCellValue(2, 1 + c, filterType);

            //get color 1
            int col1 = report_3.AddFormat(GetColor1(report_3.GetCellVisibleFormatDef(6, 2)));

            //get colo1 2
            int col2 = report_3.AddFormat(GetColor2(report_3.GetCellVisibleFormatDef(6, 2)));

            int style = col1;

            int i = 6;
            string category_1 = string.Empty;

            int dataExist = 0;

            int j = 0;
            foreach (var item in daily_trans)
            {
                dataExist = 1;
                if (i != 6 && category_1.Equals(item.Category_Name))
                    report_3.MergeCells(i - 1, 1, i, 1);

                else
                {
                    if (style == col1)
                        style = col2;
                    else
                        style = col1;
                }

                //style = res_arr[j];

                category_1 = item.Category_Name;

                report_3.SetCellValue(i, 1 + c, item.Category_Name, style);

                if (item.Goods_Name.Equals("All"))
                {
                    //get current style and add bold
                    TFlxFormat tformat = GetBold(report_3.GetCellVisibleFormatDef(i, 1 + c));
                    int res2 = report_3.AddFormat(tformat);
                    //end  style modification

                    report_3.SetCellValue(i, 2 + c, item.Goods_Name, res2);
                    report_3.SetCellValue(i, 3 + c, item.Unit, res2);
                    report_3.SetCellValue(i, 4 + c, item.Total_Quantity, res2);
                    report_3.SetCellValue(i, 5 + c, item.Total_Amount_in_SOS, res2);
                    report_3.SetCellValue(i, 6 + c, item.Total_Amount_in_USD, res2);

                }
                else
                {
                    report_3.SetCellValue(i, 2 + c, item.Goods_Name, style);
                    report_3.SetCellValue(i, 3 + c, item.Unit, style);
                    report_3.SetCellValue(i, 4 + c, item.Total_Quantity, style);
                    report_3.SetCellValue(i, 5 + c, item.Total_Amount_in_SOS, style);
                    report_3.SetCellValue(i, 6 + c, item.Total_Amount_in_USD, style);

                }

                i++;

            }

            if (dataExist <= 0)
            {
                TempData["Warning"] = "No Data To Export";
                return;
            }
            else
            {

                report_3.PrintToFit = true;
                report_3.PrintPaperSize = TPaperSize.A4;

                TWorkbookProtectionOptions protoptions = new TWorkbookProtectionOptions();
                protoptions.Window = false;
                protoptions.Structure = false;

                TSharedWorkbookProtectionOptions op = new TSharedWorkbookProtectionOptions();
                op.SharingWithTrackChanges = false;

                report_3.Protection.SetSharedWorkbookProtection("XXXX", op);
                report_3.Protection.SetWorkbookProtection("XXXX", protoptions);
                report_3.Protection.SetModifyPassword("XXXX", true, "XXXXXX");
                report_3.Protection.SetWorkbookProtectionOptions(protoptions);

                report_3.Save(copy_file_path);

                if (typ.Equals("pdf"))
                    GeneratePDF(report_3, "Report_3_"+filterType);
                else
                {
                    Response.AppendHeader("Content-Disposition", "attachment; filename=Report_3_"+filterType+".xlsx");
                    Response.TransmitFile(copy_file_path);
                    Response.End();
                }

            }
        }
开发者ID:BTEEMRIYAS,项目名称:TestProject,代码行数:101,代码来源:ReportController.cs

示例10: GerarExcel

        public void GerarExcel(string Nome_Arquivo_Origem,string Nome_Arquivo_Destino, int CodLayout, Dados d, ProgressBar statusGeracaoArquivo)
        {
            // Criando Aplicação
            XlsFile excelDestino = new XlsFile();
            XlsFile excelOrigem = new XlsFile();

            excelOrigem.Open(Nome_Arquivo_Origem);
            int QtdeLinhas = excelOrigem.RowCount;

            //Gerando arquivo de saída
            for (int i = 1; i <= excelOrigem.SheetCount; i++)
            {
                excelOrigem.ActiveSheet = i;
                excelDestino.NewFile(1);

                //LEITURA DOS DADOS ABAS
                int qtdeColunas = excelOrigem.ColCountOnlyData;

                if (qtdeColunas > 0)
                {
                    for (int cont = 1; cont <= qtdeColunas; cont++)
                    {
                        Object titulo = excelOrigem.GetCellValue(1, cont);

                        if (titulo != null)
                        {
                            string LetraColuna = d.PosicaoVinculada(CodLayout, titulo.ToString());
                            int numeroColuna;

                            try
                            {
                                numeroColuna = Convert.ToInt16(LetraColuna);
                            }
                            catch (Exception)
                            {
                                numeroColuna = LetrasParaNumero(LetraColuna);
                            }

                            if (LetraColuna != null)
                            {
                                excelDestino.InsertAndCopyRange(
                                    new TXlsCellRange(1, cont, QtdeLinhas, cont),
                                    1,
                                    numeroColuna,
                                    1,
                                    TFlxInsertMode.NoneRight,
                                    TRangeCopyMode.All,
                                    excelOrigem,
                                    i
                                );
                            }
                        }
                    }
                    int c = 0;

                    string novoNomeArquivo = Path.GetDirectoryName(Nome_Arquivo_Destino) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(Nome_Arquivo_Destino) + "_" + excelOrigem.SheetName + Path.GetExtension(Nome_Arquivo_Destino);

                    while (File.Exists(novoNomeArquivo))
                    {
                        c++;
                        novoNomeArquivo = Path.GetDirectoryName(Nome_Arquivo_Destino) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(Nome_Arquivo_Destino) + "_" + excelOrigem.SheetName + i + Path.GetExtension(Nome_Arquivo_Destino);
                    }

                    excelDestino.Save(novoNomeArquivo);
                }
                statusGeracaoArquivo.Value = statusGeracaoArquivo.Value + 1;
            }
        }
开发者ID:rafaellrochaa,项目名称:FormataLayoutExcel,代码行数:68,代码来源:ManipulaExcel.cs

示例11: Export


//.........这里部分代码省略.........
            row++;

            DataTable firstStationDataTbl = ReportHelper.GetFirstStationAvgDataTable(B, E);
            foreach (DataRow dataRow in firstStationDataTbl.Rows)
            {
                //foreach (string columnName in ReportConfig.FirstStationColumnNames)
                for (int i = 0; i < ReportConfig.FirstStationColumnNames.Length; i++)
                {
                    string columnName = ReportConfig.FirstStationColumnNames[i];
                    SetCellValue(xls, row, i + 1, dataRow[columnName], true);
                }
                row++;
            }

            // empty line
            //
            row++;

            for (int i = 0; i < ReportConfig.StationHeads.Length; i++)
            {
                SetCellValue(xls, row, i + 1, ReportConfig.StationHeads[i], true);
            }
            row++;

            //SetCellValue(xls, ReportConfig.AVGGT1, values[0]);
            //SetCellValue(xls, ReportConfig.AVGBT1, values[1]);
            //SetCellValue(xls, ReportConfig.AVGI1, values[2]);

            //SetCellValue(xls, ReportConfig.DT, DateTime.Now.ToString("yyyy-MM-dd"));

            // �պ����� = ������ * ( һ�ι��� - һ�λ��� ) * 4.1816 / 1000
            //
            DataTable tbl = ReportHelper.GetStationData(B, E);
            DataColumn heatCol = new DataColumn(
                    "heat",
                    typeof(double),
                    "(maxs1 - mins1) * (gt1 - bt1) * 4.1816 / 1000");

            tbl.Columns.Add(heatCol);

            DataColumn recuriteCol = new DataColumn("recurite",
                    typeof(double),
                    "maxsr-minsr");

            tbl.Columns.Add(recuriteCol);

            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                //int r = ReportConfig.BeginRow + i;

                FillXlsRowWithEmpty(xls, row, ReportConfig.TotalColumns);

                DataRow dataRow = tbl.Rows[i];
                double heatValue = Math.Round(Convert.ToDouble(dataRow["heat"]), ReportHelper.DotNumber);
                if (heatValue < 0)
                {
                    heatValue = 0;
                }

                SetCellValue(xls, row, ReportConfig.HeatCol,
                        heatValue,
                        true);

                SetCellValue(xls, row, ReportConfig.RecuritFluxCol,
                        Math.Round(Convert.ToDouble(dataRow["recurite"]), ReportHelper.DotNumber),
                        true);
                SetCellValue(xls, row, ReportConfig.StationNameCol,
                        dataRow["StationName"].ToString(), true);

                row++;
            }

            double sumHeat = 0d;
            double sumRecurite = 0d;

            foreach (DataRow dataRow in tbl.Rows)
            {
                double val = Convert.ToDouble(dataRow["heat"]);
                sumHeat += val < 0 ? 0 : val;
                sumRecurite += Convert.ToDouble(dataRow["recurite"]);
            }

            FillXlsRowWithEmpty(xls, row, ReportConfig.TotalColumns);
            SetCellValue(xls, row, ReportConfig.HeatCol,
                    Math.Round(sumHeat, ReportHelper.DotNumber),
                    true);

            SetCellValue(xls, row, ReportConfig.RecuritFluxCol,
                    Math.Round(sumRecurite, ReportHelper.DotNumber),
                    true);
            SetCellValue(xls, row, ReportConfig.StationNameCol,
                    "�ϼ�", true);

            row++;

            string outputPath = Xdgk.Common.Path.GetTempFileName("xls");
            xls.Save(outputPath);

            Open(outputPath);
        }
开发者ID:hkiaipc,项目名称:fnq,代码行数:101,代码来源:StationRangeDataExporter.cs

示例12: Export

        /// <summary>
        /// 
        /// </summary>
        internal override void Export()
        {
            XlsFile xls = new XlsFile();
            xls.Open(_xlsPath);

            string title = string.Format(
                    "��Դ���ɱ��Ա� {0} ~ {1}",
                    B, E);

            SetCellValue(xls, ReportConfig.Title, title);
            SetCellValue(xls, ReportConfig.AVGOT, ReportHelper.GetAvgOT(B, E));

            double[] values = ReportHelper.GetFirstValues (B,E);

            SetCellValue(xls, ReportConfig.AVGGT1, values[0]);
            SetCellValue(xls, ReportConfig.AVGBT1, values[1]);
            SetCellValue(xls, ReportConfig.AVGI1, values[2]);

            SetCellValue(xls, ReportConfig.DT, DateTime.Now.ToString("yyyy-MM-dd"));

            //
            //
            DataTable tbl = ReportHelper .GetFirstRecuriteDataTable ( B,E );

            for (int i = 0; i < tbl.Rows.Count; i++)
            {
                int r = ReportConfig.StationStartRow + i;
                // fill empty cell
                //
                for (int c = 1; c <= ReportConfig.TotalColumns; c++)
                {
                    SetCellValue(xls, r, c, null, true);
                }

                DataRow row = tbl.Rows[i];

                string name = row["stationname"].ToString();
                double usedRecurit = Math.Round(
                        Convert.ToDouble(row["usedr"]),
                        ReportHelper.DotNumber);

                //xls.SetCellValue(r, ReportConfig.StationNameCol, name);
                SetCellValue(xls, r, ReportConfig.StationNameCol, name, true);
                //xls.SetCellValue(r, ReportConfig.RecuritFluxCol, usedRecurit);
                SetCellValue(xls, r, ReportConfig.RecuritFluxCol, usedRecurit, true);

            }

            string output = Xdgk.Common.Path.GetTempFileName("xls");
            xls.Save(output);

            Open(output);
        }
开发者ID:hkiaipc,项目名称:fnq,代码行数:56,代码来源:FirstStationExporter.cs


注:本文中的XlsFile.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。