Beispiel #1
0
        private static void WriteToSheetValidator(ExcelPackage package, MotifValidator validator)
        {
            ExcelWorksheet worksheet = GetWorksheetBlank(package, "Motif Validation Sequence");
            int            rowind    = 1;

            if (validator.PositiveSpecificity > 0)
            {
                worksheet.Cells[rowind, 1].Value   = "Positive Specificity";
                worksheet.Cells[rowind++, 2].Value = validator.PositiveSpecificity;
            }
            if (validator.NegativeSpecificity > 0)
            {
                worksheet.Cells[rowind, 1].Value   = "Negative Specificity";
                worksheet.Cells[rowind++, 2].Value = validator.NegativeSpecificity;
            }

            int startrow = rowind;

            worksheet.Cells[rowind++, 1].Value = "Positive Motif only";
            worksheet.Cells[rowind, 1].Value   = "Count:";
            worksheet.Cells[rowind++, 2].Value = validator.PositiveSequenceList.Count();
            rowind = ListToExcelColumn(worksheet, rowind, 2, "Sequence", validator.PositiveSequenceList);

            rowind = startrow;
            worksheet.Cells[rowind++, 4].Value = "Including Negative Motif";
            worksheet.Cells[rowind, 4].Value   = "Count:";
            worksheet.Cells[rowind++, 5].Value = validator.NegativeSequenceList.Count();
            rowind = ListToExcelColumn(worksheet, rowind, 5, "Sequence", validator.NegativeSequenceList);

            worksheet.Column(2).AutoFit();
            worksheet.Column(5).AutoFit();
        }
Beispiel #2
0
        public static bool ExportMotifValidatorToExcel(string fileName, MotifValidator validator, bool overwrite, out string errormsg)
        {
            try
            {
                errormsg = "";
                FileInfo existingFile = new FileInfo(fileName);
                if (existingFile.Exists && !overwrite)
                {
                    return(false);
                }
                using (ExcelPackage package = new ExcelPackage(existingFile))
                {
                    if (existingFile.Exists)
                    {
                        while (package.Workbook.Worksheets.Count > 0)
                        {
                            package.Workbook.Worksheets.Delete(1);
                        }
                    }
                    WriteToSheetValidator(package, validator);
                    WriteToSheetMotif(package, validator.Motif);

                    try
                    {
                        package.Save();
                    }
                    catch
                    {
                        errormsg = "There is a problem with saving the export file. Please make sure the file is not open and you have writing rights to the specific folder.";
                        return(false);
                    }
                }
            }
            catch
            {
                errormsg = "There is a problem with creating the export file. Please try again.";
                return(false);
            }
            return(true);
        }