Hola,
Este es un job para importar directamente hojas excel, pasando por cada casilla de la hoja.
//created by Cesar Fernandez
static void ImportarTablaDesdeExcel(Args _args)
{
COM excel;
COM workBooks, workBook;
COM workSheets, workSheet;
COM celda;
COMVariant variant, variant2;
str nif, nombre, pais;
int i, encontrado, NoEncontrado;
boolean bFinFichero;
taxvatnumtable taxvatnumtable;
dialog dialog;
dialogfield df;
;
encontrado = 0;
NoEncontrado = 0;
dialog = new dialog("Seleccionar Hoja Excel");
dialog.addText("Seleccione un fichero Excel");
df = dialog.addField(typeid (filenameopen));
if ((dialog.run()) && (df.value() != "")) {
try {
variant = new COMVariant(COMVariantInOut::IN_OUT, COMVariantType::VT_VARIANT);
excel = new COM("Excel.Application");
if (excel) {
workBooks = excel.workBooks();
workBook = workBooks.open(df.value());
workSheets = workBook.workSheets();
workSheet = workSheets.item(1);
workSheet.activate();
bFinFichero = false;
for (i = 1; !bFinFichero; i++) {
celda = workSheet.range("A" + int2str((i + 1)));
variant2 = celda.value();
nif = variant2.toString();
if (variant2.toString() != "") {
celda = workSheet.range("B" + int2str((i+1)));
variant2 = celda.value();
nombre = variant2.toString();
celda = workSheet.range("C" + int2str((i+1)));
variant2 = celda.value();
pais = variant2.toString();
//Actualizamos los campos Familia y Subfamilia del registro de la InventTable
// inventTable = InventTable::find(codArt);
// if (inventTable.RecId) {
taxvatnumtable.clear();
taxvatnumtable.VATNum = nif;
taxvatnumtable.Name = nombre;
taxvatnumtable.Country = pais;
taxvatnumtable.insert();
// encontrado = encontrado + 1;
// } else {
// NoEncontrado = NoEncontrado + 1;
// }
} else {
if (i == 1) {
box::info("No hay registros en la Hoja Excel");
} else {
if (NoEncontrado != 0) {
box::info("Se ha\\n actualizado " + int2str(encontrado) +" art�culo\\s de "+ int2str((encontrado + noencontrado)));
} else{
box::info("Se ha\\n actualizado " + int2str(encontrado) +" art�culo\\s");
}
}
bFinFichero = true;
}
}
workBooks.close();
excel.finalize();
excel = NULL;
}
}catch (Exception::Deadlock){
retry;
}
}
}
Roberto Pineda <[EMAIL PROTECTED]> wrote:
Hello.
Does it have to be job?
Try using 'Definition Groups' in
Administration\Periodic\Data export/import.
--- jaiver avila <[EMAIL PROTECTED]> wrote:
>
> I am interested in the code for execute a job, for
> import DIRECTLY FROM EXCEL to table
> ledgerjournaltrans.
>
>
_________________________________________________________
> Do You Yahoo!?
> Informaci�n de Estados Unidos y Am�rica Latina, en
> Yahoo! Noticias.
> Vis�tanos en http://noticias.espanol.yahoo.com
>
>
>
>
Roberto Pineda
_________________________________________________________
Do You Yahoo!?
Informaci�n de Estados Unidos y Am�rica Latina, en Yahoo! Noticias.
Vis�tanos en http://noticias.espanol.yahoo.com
---------------------------------
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/development-axapta/
To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
[Non-text portions of this message have been removed]
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/development-axapta/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

