Salut l'équipe,
Quelqu'un a-t-il déjà importé des images depuis une feuille de calcul Excel ? Idéalement, avec les données de la feuille de calcul également ?
Cela ne semble pas possible, mais je ne serais pas surpris si quelqu'un ici avait réussi à réaliser l'impossible.;)
Meilleur
Florian
Salut @Florian_Vogt ,
Comme les données d'image dans les fichiers Excel (.xlsx) sont stockées en interne dans un format ZIP, vous pouvez extraire des images à l'aide du code JSL suivant.
// Open the Excel file (.xlsx) as a ZIP archive
za = Open( "$desktop\Big Class Families.xlsx", zip );
// Get the list of files inside the ZIP archive
dirlist = za << dir;
// Create a new data table with one column to store images
dt = New Table( "Import image from Excel", New Column( "Image", Expression ) );
// Initialize row index
row_i = 0;
// Loop through all files in the ZIP archive
For( p_i = 1, p_i <= N Items( dirlist ), p_i++,
// Check if the file has a .png extension (i.e., it's an image)
If( Right( dirlist[p_i], 4 ) == ".png" /*png data*/,
// Read the PNG file as binary (blob) data
myImageBlob = za << read( dirlist[p_i], Format( blob ) );
// Convert the binary data into an image object
myImage = New Image( myImageBlob, "png" );
// Add a new row to the data table
dt << Add Rows( 1 );
row_i++;
// Insert the image into the first column of the new row
dt[row_i, 1] = myImage;
)
);
If you also need to retrieve associated data or the location of the images within the worksheet, I recommend using a Python library such as openpyxl.
J'espère que cela aide !
Arrigato gozaimasu, Yuichi-san !