You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include <xlnt/xlnt.hpp>
using namespace std;
...
void Widget::on_abrir_clicked()
{
QFileDialog fd;//--------------------------------caja de dialogo para que tome el excel
fd.setDefaultSuffix(".xlsx");
fd.setDirectory(QDir::homePath());
nombre_de_file = fd.getOpenFileName();
// nombre_de_file = nombre_de_file.split("/").join("\"); // first try
// nombre_de_file.insert(nombre_de_file.indexOf("\"), "\");
nombre_de_file.insert(nombre_de_file.indexOf("/"), "/"); // second try
if (nombre_de_file.isEmpty() || nombre_de_file.isNull())
{
nombre_de_file= filename_anterior;
ui->espere_cartel->hide(); ui->progressBar->hide();
return;
}
QFileInfo archinfo;
archinfo.setFile(nombre_de_file);
if (archinfo.suffix().contains("xls") == false){
QMessageBox::critical(this, "Error: no es un archivo Excel",
"El archivo seleccionado no es un archivo Excel como se espera. Seleccione correctamente el archivo.");
nombre_de_file = "";
ui->espere_cartel->hide();
ui->progressBar->hide();return; //salir
}
xlnt::path ruta(nombre_de_file.toStdString());
xlnt::workbook xlsx; //solo para leer la informacion
try{
xlsx.load(ruta); // Here *********************************** an exception
}catch(...)
{
mSystemTrayIcon->showMessage("Nuevo Mensaje",
"Hay un mensaje de error para usted en el Control de Embarazadas.");
QString s1 = e.what();
QMessageBox::critical(nullptr,
"Error de archivo",
"Exception: "+
s1 +
". Error al abrir el archivo. Esto puede deberse a que otro programa tiene abierto el archivo, o se ha generado una excepción. Si es así, trate de cerrar el archivo en el otro programa primero.");
nombre_de_file = "";
ui->abrir->setEnabled(0);
ui->espere_cartel->hide();
ui->progressBar->hide();return; //salir
}
...
It generate an exception in the load line:
in my first try, xlnt::exception File not found F:\new folder\example.xlsx
second try , xlnt::exception File not found F:\new folder\example.xlsx
third try: xlnt::exception File not found F://new folder/example.xlsx
four try: xlnt::exception File not found F:/new folder/example.xlsx
I'll thanks a lot if somebody can help me.
The text was updated successfully, but these errors were encountered:
xlnt::workbook xlsx(ruta); //with this I think it can read the file
The simple examples of Qxlnt in internet teach it.
I found that method load it's not for my purpose. But I need to make some probes to reach my objective.
Hi.
I have that xlnt can't read the excel file in Windows 10, 64 bits. I'm using Qt creator, but I'm relatively new to modern code.
Some code:
#include "widget.h"
#include "ui_widget.h"
#include "persona_reducida.h"
#include "personadialog.h"
#include "listadobusq_o_err_dialog.h"
#include "filtro.h"
#include <operaciones_con_qstrings.h>
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include <xlnt/xlnt.hpp>
using namespace std;
...
void Widget::on_abrir_clicked()
{
QFileDialog fd;//--------------------------------caja de dialogo para que tome el excel
fd.setDefaultSuffix(".xlsx");
fd.setDirectory(QDir::homePath());
nombre_de_file = fd.getOpenFileName();
// nombre_de_file = nombre_de_file.split("/").join("\"); // first try
// nombre_de_file.insert(nombre_de_file.indexOf("\"), "\");
nombre_de_file.insert(nombre_de_file.indexOf("/"), "/"); // second try
if (nombre_de_file.isEmpty() || nombre_de_file.isNull())
{
nombre_de_file= filename_anterior;
ui->espere_cartel->hide(); ui->progressBar->hide();
return;
}
QFileInfo archinfo;
archinfo.setFile(nombre_de_file);
if (archinfo.suffix().contains("xls") == false){
QMessageBox::critical(this, "Error: no es un archivo Excel",
"El archivo seleccionado no es un archivo Excel como se espera. Seleccione correctamente el archivo.");
nombre_de_file = "";
ui->espere_cartel->hide();
ui->progressBar->hide();return; //salir
}
xlnt::path ruta(nombre_de_file.toStdString());
xlnt::workbook xlsx; //solo para leer la informacion
try{
xlsx.load(ruta); // Here *********************************** an exception
}catch(...)
{
mSystemTrayIcon->showMessage("Nuevo Mensaje",
"Hay un mensaje de error para usted en el Control de Embarazadas.");
QString s1 = e.what();
QMessageBox::critical(nullptr,
"Error de archivo",
"Exception: "+
s1 +
". Error al abrir el archivo. Esto puede deberse a que otro programa tiene abierto el archivo, o se ha generado una excepción. Si es así, trate de cerrar el archivo en el otro programa primero.");
nombre_de_file = "";
ui->abrir->setEnabled(0);
ui->espere_cartel->hide();
ui->progressBar->hide();return; //salir
}
...
It generate an exception in the load line:
in my first try, xlnt::exception File not found F:\new folder\example.xlsx
second try , xlnt::exception File not found F:\new folder\example.xlsx
third try: xlnt::exception File not found F://new folder/example.xlsx
four try: xlnt::exception File not found F:/new folder/example.xlsx
I'll thanks a lot if somebody can help me.
The text was updated successfully, but these errors were encountered: