» »

Excel uvoz slik

Excel uvoz slik

foofighter ::

Zdravo,
ima kdo kakšno idejo na kakšen način bi v excel uvažal slike glede na njihovo ime.

V stolpcu A bi imel napisane šifre. Recimo:

1
2
3
4
5
6

Nekje na disku bi imel mapo, v kateri bi bile slike, imenovane z šiframi iz stolpca A.

Kako bi najlažje naredil da mi v stolec B uvozi slike tako, da se bom ime slike ujemalo z šifro, ki je že v excelu?

Hvala za pomoč.

milc ::

V perlu takole:
use 5.012;
use strict;
use warnings;
use Spreadsheet::WriteExcel;

use Spreadsheet::ParseExcel;
use Spreadsheet::ParseExcel::SaveParser;


# Create a new Excel workbook - add some test image names
{
  my $wb = Spreadsheet::WriteExcel->new('perl-test.xls');
  # Add a worksheet
  my $ws = $wb->add_worksheet('Sheet1');

  # Write a formatted and unformatted string, row and column notation.
  my $col = my $row = 0;
  for (1..3) {
    $ws->write($row++, $col, 'pic1.jpg');
    $ws->write($row++, $col, 'pic2.jpg');
    $ws->write($row++, $col, 'pic3.jpg');
  }
  $wb->close();
}



# Create a new Excel workbook  - RESULT
my $wbn = Spreadsheet::WriteExcel->new('perl-test-img.xls');
# Add a worksheet
my $wsn = $wbn->add_worksheet('Sheet1');


# Open the template with SaveParser
my $parser   = new Spreadsheet::ParseExcel::SaveParser;
my $template = $parser->Parse('perl-test.xls');

my $sheet    = 0;
my $row      = 0;
my $col      = 0;

# Get the format from the cell
my $frmt  = $template->{Worksheet}[$sheet]
                     ->{Cells}[$row][$col]
                     ->{FormatNo};

my $worksheet = $template->worksheet(0);
my $value;
my $cell = $worksheet->get_cell($row, $col);
while (defined $cell && $cell->value()) {
  my $filename = $value = $cell->value();

  #insert_image($row, $col, $filename, $x, $y, $scale_x, $scale_y)
  if (-f $filename) {
    say "$row: $value; added";
    $wsn->write($row, $col, $filename, $frmt);
    $wsn->insert_image($row, $col+1, $filename);
  } else {
    my $error= "Picture: $filename does not exists";
    say $error;
    $wsn->write($row, $col, $filename, $frmt);
    $wsn->write($row, $col+1, $error, $frmt);
  } #if
  $cell = $worksheet->get_cell(++$row, $col);
} # while

$wbn->close();


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

[Java] Urejanje baze z JTable

Oddelek: Programiranje
81030 (814) vonNeumann
»

button v image button

Oddelek: Izdelava spletišč
91246 (1151) R33D3M33R
»

Excel vprašanje...printanje n-krat...vsakič se avtomatsko poveča ena številka

Oddelek: Programska oprema
121266 (1149) Tutankhamun
»

Prosim za pomoč pri VBA

Oddelek: Programiranje
352120 (1923) apachee
»

Visual Basic in Excel

Oddelek: Programiranje
262697 (2263) Vesoljc

Več podobnih tem