Example #1
0
        /// <summary>
        /// Loads the BibTex file and converts it to Excel
        /// </summary>
        /// <param name="filePath">The file path.</param>
        /// <param name="author">The author.</param>
        /// <param name="log">The log.</param>
        /// <param name="customTemplate">Custom data annotation template, to be used for Excel file generation. If not specified, default <see cref="template"/> is used</param>
        /// <returns>Extended DataTable that is written in Excel file</returns>
        public static DataTableForStatistics ExportToExcel(String filePath, aceAuthorNotation author, ILogBuilder log = null, propertyAnnotationPreset customTemplate = null, folderNode outputFolder = null)
        {
            BibTexDataFile bibFile = new BibTexDataFile(filePath);
            FileInfo       fi      = new FileInfo(filePath);

            if (outputFolder == null)
            {
                outputFolder = fi.Directory;
            }

            if (customTemplate == null)
            {
                customTemplate = template;
            }

            DataTable reportTable = bibFile.ConvertToDataTable(null, customTemplate, log); //.GetReportAndSave(fi.Directory, author, bibFile.name);

            DataTableForStatistics report = reportTable.GetReportAndSave(outputFolder, author);

            if (log != null)
            {
                log.log("BibTex [" + filePath + "] -> Excel [" + report.lastFilePath + "]");
            }

            return(report);
        }
        /// <summary>
        /// Gets the data file object model
        /// </summary>
        /// <param name="filename">The filename, without extension</param>
        /// <param name="table">LaTeX translation table</param>
        /// <param name="log">The log.</param>
        /// <returns></returns>
        public BibTexDataFile GetDataFile(String filename, translationTextTable table, ILogBuilder log = null)
        {
            BibTexDataFile file = new BibTexDataFile();

            file.name = filename;
            foreach (BibTexEntryModel emodel in this)
            {
                file.UntypedEntries.Add(emodel.GetEntry(table, log));
            }
            return(file);
        }
        /// <summary>Method demonstrating basic operation of loading BibTex file</summary>

        /** <example><para>Method demonstrating basic operation of loading BibTex file</para>
         *  <code> // Example 1: Loading BibTex file
         *  BibTexDataFile bib_1 = new BibTexDataFile("Resources\\test\\S0306457309000259.bib");
         *  // Converting BibTex data into object model dictionary
         *  System.Collections.Generic.Dictionary{string, BibTexEntryModel} model = bib_1.ConvertToModel(log);
         *  // Printing [Author : Title] to a ILogBuilder log builder
         *  foreach (var pair in model)
         *  {
         *      log.log(pair.Value.author.or("Unknown") + ": " + pair.Value.title);
         *  }
         *  </code></example>
         */
        public void Example1_Basic()
        {
            // Example 1: Loading BibTex file
            BibTexDataFile bib_1 = new BibTexDataFile("Resources\\test\\S0306457309000259.bib");

            // Converting BibTex data into object model dictionary
            BibTexCollection <BibTexEntryModel> model = bib_1.ConvertToModel <BibTexEntryModel>(log);

            // Printing [Author : Title] to a ILogBuilder log builder
            foreach (var pair in model)
            {
                log.log(pair.author.or("Unknown") + ": " + pair.title);
            }
        }
        /// <summary>Load BibTex file, convert data into DataTable, create Excel file without Legend information and generate full Excel report</summary>

        /** <example><para>Load BibTex file, convert data into DataTable, create Excel file without Legend information and generate full Excel report</para>
         *  <code>
         *   // Example 2: Loading BibTex file
         *  String path = folderResources.findFile("S0306457309000259.bib", SearchOption.AllDirectories);
         *
         *  // initializes bibtex data file object
         *  BibTexDataFile bib = new BibTexDataFile();
         *
         *  // loads .bib or .bibtex file from path specified
         *  bib.Load(path, log);
         *
         *  // converts loaded BibTex entries into DataTable, with all columns discovered in the entries
         *  DataTable dt = bib.ConvertToDataTable();
         *
         *  // saves DataTable to Excel file, without adding Legend spreadsheet
         *  var finalPath = dt.serializeDataTable(Data.enums.reporting.dataTableExportEnum.excel, bib.name, folderResults, notation);
         *
         *  // creates extended version of Excel file, with additional spreadsheet for Legend and other meta information
         *  var reportDataTable_ref = dt.GetReportAndSave(folderResults, notation);</code></example>
         */

        public void Example2_LoadAndExport()
        {
            // Example 2: Loading BibTex file
            String path = folderResources.findFile("S0306457309000259.bib", SearchOption.AllDirectories);

            // initializes bibtex data file object
            BibTexDataFile bib = new BibTexDataFile();

            // loads .bib or .bibtex file from path specified
            bib.Load(path, log);

            // converts loaded BibTex entries into DataTable, with all columns discovered in the entries
            DataTable dt = bib.ConvertToDataTable();

            // saves DataTable to Excel file, without adding Legend spreadsheet
            var finalPath = dt.serializeDataTable(Data.enums.reporting.dataTableExportEnum.excel, bib.name, folderResults, notation);

            // creates extended version of Excel file, with additional spreadsheet for Legend and other meta information
            var reportDataTable_ref = dt.GetReportAndSave(folderResults, notation);
        }