Пример #1
0
        /// <summary>
        /// Evento disparado quando uma nova linha é incluída.
        /// </summary>
        /// <param name="p_sheet">Planilha do template.</param>
        private void OnDataRow(Spartacus.ThirdParty.SejExcel.gSheet p_sheet)
        {
            Spartacus.Utils.Excel.Sheet v_info;
            System.Data.DataRow v_row;
            string[] v_tmp;
            int v_in_value;
            double v_re_value;
            string v_tail;

            v_info = (Spartacus.Utils.Excel.Sheet) this.v_sheets [p_sheet.Index-1];

            if ((v_info.v_currentrow - v_info.v_fixedrows - 1) < v_info.v_data.Rows.Count)
            {
                p_sheet.BeginRow(v_info.v_currentrow);
                v_row = v_info.v_data.Rows [v_info.v_currentrow - v_info.v_fixedrows - 1];
                foreach (System.Collections.Generic.KeyValuePair<int,string> v_pair in v_info.v_mapping)
                {
                    v_tmp = v_pair.Value.Split('_');
                    v_tail = v_pair.Value.Substring(3);

                    switch (v_tmp [0].ToLower())
                    {
                        case "in":
                            if (int.TryParse(v_row [v_tail].ToString(), out v_in_value))
                                p_sheet.WriteCell(v_pair.Key, v_in_value);
                            else
                                p_sheet.WriteCell(v_pair.Key, v_row [v_tail].ToString());
                            break;
                        case "dt":
                            if (int.TryParse(v_row [v_tail].ToString(), out v_in_value))
                                p_sheet.WriteCell(v_pair.Key, v_in_value);
                            else
                                p_sheet.WriteCell(v_pair.Key, v_row [v_tail].ToString());
                            break;
                        case "re":
                            if (double.TryParse(v_row[v_tail].ToString().Replace(",", "."), System.Globalization.NumberStyles.Any, new System.Globalization.CultureInfo("en-US"), out v_re_value))
                                p_sheet.WriteCell(v_pair.Key, v_re_value);
                            else
                                p_sheet.WriteCell(v_pair.Key, v_row [v_tail].ToString());
                            break;
                        default:
                            p_sheet.WriteCell(v_pair.Key, v_row [v_tail].ToString());
                            break;
                    }
                }
                p_sheet.EndRow();

                ((Spartacus.Utils.Excel.Sheet) this.v_sheets [p_sheet.Index - 1]).v_currentrow++;

                this.v_perc += this.v_inc;
                this.v_currentrow++;
                this.v_progress.FireEvent("Spartacus.Utils.Excel", "ExportXLSX", this.v_perc, "Planilha " + ((Spartacus.Utils.Excel.Sheet) this.v_sheets [p_sheet.Index - 1]).v_name + ": linha " + this.v_currentrow.ToString() + " de " + this.v_numtotalrows.ToString());
            }
        }