Click here to Skip to main content
15,347,117 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I work on core 2.2 i face issue I can't

modify web api to display message "Not Matched Compare" when compare excel function return false (areIdentical == false) .

web api below return physical file as zip file

in case of compare excel return true

but I need when compare excel function return false

to display message "Not matched compare"

so How to do it please ?

expected result

if (areIdentical == false)
return "Not Matched Compare"

so How to do that ?

What I have tried:

public IActionResult ExportNormalizedRelation()

        var InputfilePath = System.IO.Path.Combine(GetFilesDownload, "DeliveryGenerationNormalTest_Input.xlsx");
        using (var stream = new FileStream(dbPath, FileMode.Create))
        bool areIdentical = ex.CompareExcel(dbPath, InputfilePath, out rowCount, out error);
        if (areIdentical == true)

            pathToCreate = Path.Combine(myValue2,Month,"file" + DateTime.Now.Ticks.ToString());

                List<inputexcelnormaltest> inputexcellist = new List<inputexcelnormaltest>();
                inputexcellist = ex.ImportNormalTest(dbPath);
                List<string> tabs = new List<string>();
                var outputTemplatePath = System.IO.Path.Combine(GetFilesDownload, "DeliveryGeneration_Output.xlsx");
                List<inputexcelnormaltest> inputmodulelist = new List<inputexcelnormaltest>();

                        foreach (var m in tabs)
                            inputmodulelist = inputexcellist.Where(x => (x.TabName == m && x.FileName == f)).ToList();
                            var dtimport = DatatableConversion.ToDataTable(inputmodulelist);
                            DataTable dtexport = new DataTable();

                            dtexport = _deliveryService.LoadExcelToDataTableZipData(_connectionString, dtimport);

                            ex.Export(dtexport, m, exportPath);




        string zipPath = Path.Combine(myValue2,Month,"result" + DateTime.Now.Ticks.ToString() + ".zip");

        ZipFile.CreateFromDirectory(pathToCreate, zipPath);

        return PhysicalFile(zipPath, "application/zip", Path.GetFileName(zipPath));
Richard MacCutchan 2-Apr-22 4:24am
bool areIdentical = ex.CompareExcel(dbPath, InputfilePath, out rowCount, out error);

Where is the code that performs this action, and what is it trying to compare?
ahmed_sa 2-Apr-22 6:07am
it compare two excel file and if it matched then it return file and if not then it must return message not matched

function compare excel

public bool CompareExcel(string filePath, string templatePath, out int rowCount, out string error)
error = ""; rowCount = 0;
bool areIdentical = false;
string templateSheetName = "";
List<string> columns;
GetTemplateSchema(templatePath, out templateSheetName, out columns);
areIdentical = CompareBySchema(filePath, templateSheetName, columns, out rowCount, out error);
return areIdentical;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900