In my app I use libxl library for read xls[x] files. Data taken from the files and shown into the table QTableWidget. But now I need to add support for read csv files. How I can do it compatible with current code (with libxl methods load(), getSheet() etc) (libxl doesn't support csv).
Book* book;
if (excelfileName.endsWith(".xlsx")) {
book = xlCreateXMLBook();
} else if (excelfileName.endsWith(".xls")) {
book = xlCreateBook();
} else {
book = new CSVBook();
}
book->load(excelfileName.toLocal8Bit().data());
Which design pattern I should use for it?
To do it I created new class csvbook
and redeclare all virtual methods from IBookT. At next step I wrote body for all methods of csvbook at the same file with declaration.
Object created in function
And as result