예제 #1
0
        /// <summary>
        /// Exports the data to a table.
        /// </summary>
        /// <param name="filename">The filename.</param>
        /// <param name="targetPath">The target path.</param>
        /// <param name="sheetTitle">The sheet title.</param>
        private void _Export(string filename, string targetPath, string sheetTitle)
        {
            if (this._movies != null &&
                this._movies.Count > 0)
            {
                this.lblState.Text = "Sammle Informationen...";
                this.lblState.Refresh();
                this.lblState.Update();

                this.lblState.Text = "Sammle Informationen: Lade zusätzliche Daten...";
                this.lblState.Refresh();
                this.lblState.Update();

                this._movies = this._db.AddMovieAdditionals(this._movies);

                ExcelExport.Document doc = new ExcelExport.Document();

                doc.SheetTitle = sheetTitle;

                //if(this._ColumnIsChoosen("No.")) {
                //    doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Nummer", Width = 50 });
                //}

                //if(this._ColumnIsChoosen("Name")) {
                //    doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Name", Width = 250 });
                //}

                //if(this._ColumnIsChoosen("Genre")) {
                //    doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Genre", Width = 140 });
                //}

                //doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Codec", Width = 70 });
                //doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Anzahl CD's", Width = 40 });

                int count = 0;

                this.lblState.Text = "Sammle Informationen: Spalten hinzufügen...";
                this.lblState.Refresh();
                this.lblState.Update();

                foreach (CheckBox chk in this.colsPanel.Controls)
                {
                    if (chk.Checked)
                    {
                        ExcelExport.TableColumn col = new ExcelExport.TableColumn();

                        col.Value = chk.Text;
                        col.Width = 40;

                        if (chk.Text.Contains("Nr."))
                        {
                            col.Value = "Nummer";
                            col.Width = 50;
                        }
                        else if (chk.Text.Contains("Name"))
                        {
                            col.Width = 250;
                        }
                        else if (chk.Text.Contains("Genre"))
                        {
                            col.Width = 140;
                        }
                        else if (chk.Text.Contains("Codec"))
                        {
                            col.Width = 70;
                        }
                        else if (chk.Text.Contains("Discs"))
                        {
                            col.Value = "Anzahl CD's";
                            col.Width = 40;
                        }
                        else if (chk.Text.Contains("Land"))
                        {
                            col.Width = 250;
                        }
                        else if (chk.Text.Contains("Kategorie"))
                        {
                            col.Width = 140;
                        }
                        else if (chk.Text.Contains("Qualität"))
                        {
                            col.Width = 50;
                        }
                        else if (chk.Text.Contains("Original"))
                        {
                            col.Width = 40;
                        }
                        else if (chk.Text.Contains("Darsteller"))
                        {
                            col.Width = 250;
                        }
                        else if (chk.Text.Contains("Regisseur"))
                        {
                            col.Width = 250;
                        }
                        else if (chk.Text.Contains("Produzent"))
                        {
                            col.Width = 250;
                        }

                        doc.Columns.Add(col);

                        count++;
                    }

                    //this.pbState.PerformStep();
                    this.pbState.Value += 1;
                    this.pbState.Refresh();
                    this.pbState.Update();

                    this.lblState.Text = "Sammle Informationen: Spalte " + count.ToString() + " hinzugefügt...";
                    this.lblState.Refresh();
                    this.lblState.Update();
                }

                //doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Darsteller", Width = 250 });
                //doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Regisseur", Width = 250 });
                //doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Produzent", Width = 250 });

                count = 1;

                this.lblState.Text = "Sammle Informationen: Filme hinzufügen...";
                this.lblState.Refresh();
                this.lblState.Update();

                foreach (Movie mov in this._movies)
                {
                    //ExcelExportDataContainer obj = new ExcelExportDataContainer();

                    //// columns
                    //obj.Columns.Add("Nummer");
                    //obj.Columns.Add("Name");
                    //obj.Columns.Add("Genre");
                    //obj.Columns.Add("Codec");
                    //obj.Columns.Add("Anzahl CD's");
                    ////obj.Columns.Add("Country");
                    //obj.Columns.Add("Actor");
                    //obj.Columns.Add("Director");
                    //obj.Columns.Add("Producer");

                    //Static stc = this._sb.GetStaticItem("C002", mov.Country);

                    // cells
                    ExcelExport.DataContainer obj = new ExcelExport.DataContainer();

                    foreach (CheckBox chk in this.colsPanel.Controls)
                    {
                        if (chk.Checked)
                        {
                            ExcelExport.TableCell cell = new ExcelExport.TableCell();

                            cell.Type  = "String";
                            cell.Value = "";

                            if (chk.Text.Contains("Nr."))
                            {
                                cell.Value = mov.Number.ToString();
                                cell.Type  = "Number";
                            }
                            else if (chk.Text.Contains("Name"))
                            {
                                cell.Value = mov.Name;
                            }
                            else if (chk.Text.Contains("Genre"))
                            {
                                cell.Value = mov.GenerateGenresString;
                            }
                            else if (chk.Text.Contains("Codec"))
                            {
                                cell.Value = (mov.Codec == Codec.Unknown ? "" : mov.Codec.ToString());
                            }
                            else if (chk.Text.Contains("Discs"))
                            {
                                cell.Value = mov.DiscAmount.ToString();
                                cell.Type  = "Number";
                            }
                            else if (chk.Text.Contains("Original"))
                            {
                                cell.Value = mov.IsOriginal.ToString();
                            }
                            else if (chk.Text.Contains("Kategorie"))
                            {
                                cell.Value = mov.GenerateCategoriesString;
                            }
                            else if (chk.Text.Contains("Land"))
                            {
                                Static stc = this._sb.GetStaticItem("C002", mov.Country);
                                cell.Value = stc.Content;
                            }
                            else if (chk.Text.Contains("Darsteller"))
                            {
                                cell.Value = mov.GenerateActorsString;
                            }
                            else if (chk.Text.Contains("Regisseur"))
                            {
                                cell.Value = mov.GenerateDirectorsString;
                            }
                            else if (chk.Text.Contains("Produzent"))
                            {
                                cell.Value = mov.GenerateProducersString;
                            }

                            obj.Cells.Add(cell);
                        }
                    }

                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.Number.ToString(), Type = "Number" });
                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.Name, Type = "String" });
                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.GenerateGenresString, Type = "String" });
                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = ( mov.Codec == Codec.Unknown ? "" : mov.Codec.ToString() ), Type = "String" });
                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.DiscAmount.ToString(), Type = "String" });

                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.ActorsString, Type = "String" });
                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.DirectorsString, Type = "String" });
                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.ProducersString, Type = "String" });

                    //obj.Cells.Add(mov.Number.ToString());
                    //obj.Cells.Add(mov.Name);
                    //obj.Cells.Add(mov.GenerateGenresString);
                    //obj.Cells.Add((mov.Codec == Codec.Unknown ? "" : mov.Codec.ToString()));
                    //obj.Cells.Add(mov.DiscAmount.ToString());
                    //obj.Cells.Add(stc.Content);
                    //obj.Cells.Add(mov.ActorsString);
                    //obj.Cells.Add(mov.DirectorsString);
                    //obj.Cells.Add(mov.ProducersString);

                    doc.Data.Add(obj);

                    //this.pbState.PerformStep();
                    this.pbState.Value += 1;
                    this.pbState.Refresh();
                    this.pbState.Update();

                    this.lblState.Text = "Sammle Informationen: Film " + count.ToString() + " hinzugefügt...";
                    this.lblState.Refresh();
                    this.lblState.Update();

                    count++;
                }

                this.pbState.Value   = 0;
                this.pbState.Maximum = doc.ColumnAndCellCount;

                // save now
                this._filename = Path.GetFullPath(targetPath + "\\" + filename);

                this.lblState.Text = "Informationen geladen, starte nun Export...";

                this.lblState.Refresh();
                this.lblState.Update();

                this._export.ExportDocument(doc, this._filename, true);

                //try {
                //    AppLoader loader = new AppLoader();
                //    loader.LoadApp(this._filename);
                //}
                //catch(Exception ex) {
                //    StaticWindows.ErrorBox(ex.Message);
                //}
            }
        }
예제 #2
0
        /// <summary>
        /// Exports the data to a table.
        /// </summary>
        /// <param name="filename">The filename.</param>
        /// <param name="targetPath">The target path.</param>
        /// <param name="sheetTitle">The sheet title.</param>
        private void _Export(string filename, string targetPath, string sheetTitle)
        {
            if(this._movies != null
            && this._movies.Count > 0) {
                this.lblState.Text = "Sammle Informationen...";
                this.lblState.Refresh();
                this.lblState.Update();

                this.lblState.Text = "Sammle Informationen: Lade zusätzliche Daten...";
                this.lblState.Refresh();
                this.lblState.Update();

                this._movies = this._db.AddMovieAdditionals(this._movies);

                ExcelExport.Document doc = new ExcelExport.Document();

                doc.SheetTitle = sheetTitle;

                //if(this._ColumnIsChoosen("No.")) {
                //    doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Nummer", Width = 50 });
                //}

                //if(this._ColumnIsChoosen("Name")) {
                //    doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Name", Width = 250 });
                //}

                //if(this._ColumnIsChoosen("Genre")) {
                //    doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Genre", Width = 140 });
                //}

                //doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Codec", Width = 70 });
                //doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Anzahl CD's", Width = 40 });

                int count = 0;

                this.lblState.Text = "Sammle Informationen: Spalten hinzufügen...";
                this.lblState.Refresh();
                this.lblState.Update();

                foreach(CheckBox chk in this.colsPanel.Controls) {
                    if(chk.Checked) {
                        ExcelExport.TableColumn col = new ExcelExport.TableColumn();

                        col.Value = chk.Text;
                        col.Width = 40;

                        if(chk.Text.Contains("Nr.")) {
                            col.Value = "Nummer";
                            col.Width = 50;
                        }
                        else if(chk.Text.Contains("Name")) {
                            col.Width = 250;
                        }
                        else if(chk.Text.Contains("Genre")) {
                            col.Width = 140;
                        }
                        else if(chk.Text.Contains("Codec")) {
                            col.Width = 70;
                        }
                        else if(chk.Text.Contains("Discs")) {
                            col.Value = "Anzahl CD's";
                            col.Width = 40;
                        }
                        else if(chk.Text.Contains("Land")) {
                            col.Width = 250;
                        }
                        else if(chk.Text.Contains("Kategorie")) {
                            col.Width = 140;
                        }
                        else if(chk.Text.Contains("Qualität")) {
                            col.Width = 50;
                        }
                        else if(chk.Text.Contains("Original")) {
                            col.Width = 40;
                        }
                        else if(chk.Text.Contains("Darsteller")) {
                            col.Width = 250;
                        }
                        else if(chk.Text.Contains("Regisseur")) {
                            col.Width = 250;
                        }
                        else if(chk.Text.Contains("Produzent")) {
                            col.Width = 250;
                        }

                        doc.Columns.Add(col);

                        count++;
                    }

                    //this.pbState.PerformStep();
                    this.pbState.Value += 1;
                    this.pbState.Refresh();
                    this.pbState.Update();

                    this.lblState.Text = "Sammle Informationen: Spalte " + count.ToString() + " hinzugefügt...";
                    this.lblState.Refresh();
                    this.lblState.Update();
                }

                //doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Darsteller", Width = 250 });
                //doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Regisseur", Width = 250 });
                //doc.Columns.Add(new ExcelExport.TableColumn() { Value = "Produzent", Width = 250 });

                count = 1;

                this.lblState.Text = "Sammle Informationen: Filme hinzufügen...";
                this.lblState.Refresh();
                this.lblState.Update();

                foreach(Movie mov in this._movies) {
                    //ExcelExportDataContainer obj = new ExcelExportDataContainer();

                    //// columns
                    //obj.Columns.Add("Nummer");
                    //obj.Columns.Add("Name");
                    //obj.Columns.Add("Genre");
                    //obj.Columns.Add("Codec");
                    //obj.Columns.Add("Anzahl CD's");
                    ////obj.Columns.Add("Country");
                    //obj.Columns.Add("Actor");
                    //obj.Columns.Add("Director");
                    //obj.Columns.Add("Producer");

                    //Static stc = this._sb.GetStaticItem("C002", mov.Country);

                    // cells
                    ExcelExport.DataContainer obj = new ExcelExport.DataContainer();

                    foreach(CheckBox chk in this.colsPanel.Controls) {
                        if(chk.Checked) {
                            ExcelExport.TableCell cell = new ExcelExport.TableCell();

                            cell.Type = "String";
                            cell.Value = "";

                            if(chk.Text.Contains("Nr.")) {
                                cell.Value = mov.Number.ToString();
                                cell.Type = "Number";
                            }
                            else if(chk.Text.Contains("Name")) {
                                cell.Value = mov.Name;
                            }
                            else if(chk.Text.Contains("Genre")) {
                                cell.Value = mov.GenerateGenresString;
                            }
                            else if(chk.Text.Contains("Codec")) {
                                cell.Value = ( mov.Codec == Codec.Unknown ? "" : mov.Codec.ToString() );
                            }
                            else if(chk.Text.Contains("Discs")) {
                                cell.Value = mov.DiscAmount.ToString();
                                cell.Type = "Number";
                            }
                            else if(chk.Text.Contains("Original")) {
                                cell.Value = mov.IsOriginal.ToString();
                            }
                            else if(chk.Text.Contains("Kategorie")) {
                                cell.Value = mov.GenerateCategoriesString;
                            }
                            else if(chk.Text.Contains("Land")) {
                                Static stc = this._sb.GetStaticItem("C002", mov.Country);
                                cell.Value = stc.Content;
                            }
                            else if(chk.Text.Contains("Darsteller")) {
                                cell.Value = mov.GenerateActorsString;
                            }
                            else if(chk.Text.Contains("Regisseur")) {
                                cell.Value = mov.GenerateDirectorsString;
                            }
                            else if(chk.Text.Contains("Produzent")) {
                                cell.Value = mov.GenerateProducersString;
                            }

                            obj.Cells.Add(cell);
                        }
                    }

                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.Number.ToString(), Type = "Number" });
                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.Name, Type = "String" });
                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.GenerateGenresString, Type = "String" });
                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = ( mov.Codec == Codec.Unknown ? "" : mov.Codec.ToString() ), Type = "String" });
                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.DiscAmount.ToString(), Type = "String" });

                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.ActorsString, Type = "String" });
                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.DirectorsString, Type = "String" });
                    //obj.Cells.Add(new ExcelExport.TableCell() { Value = mov.ProducersString, Type = "String" });

                    //obj.Cells.Add(mov.Number.ToString());
                    //obj.Cells.Add(mov.Name);
                    //obj.Cells.Add(mov.GenerateGenresString);
                    //obj.Cells.Add((mov.Codec == Codec.Unknown ? "" : mov.Codec.ToString()));
                    //obj.Cells.Add(mov.DiscAmount.ToString());
                    //obj.Cells.Add(stc.Content);
                    //obj.Cells.Add(mov.ActorsString);
                    //obj.Cells.Add(mov.DirectorsString);
                    //obj.Cells.Add(mov.ProducersString);

                    doc.Data.Add(obj);

                    //this.pbState.PerformStep();
                    this.pbState.Value += 1;
                    this.pbState.Refresh();
                    this.pbState.Update();

                    this.lblState.Text = "Sammle Informationen: Film " + count.ToString() + " hinzugefügt...";
                    this.lblState.Refresh();
                    this.lblState.Update();

                    count++;
                }

                this.pbState.Value = 0;
                this.pbState.Maximum = doc.ColumnAndCellCount;

                // save now
                this._filename = Path.GetFullPath(targetPath + "\\" + filename);

                this.lblState.Text = "Informationen geladen, starte nun Export...";

                this.lblState.Refresh();
                this.lblState.Update();

                this._export.ExportDocument(doc, this._filename, true);

                //try {
                //    AppLoader loader = new AppLoader();
                //    loader.LoadApp(this._filename);
                //}
                //catch(Exception ex) {
                //    StaticWindows.ErrorBox(ex.Message);
                //}
            }
        }