Thread Eine Excel-Spalte nach Daten durchsuchen!
(2 answers)
Opened by Lauvia at 2013-11-27 11:45
Hmmmm hat keiner eine Idee?
ich habe mir eine kleine Routine geschrieben, die die B-Spalte schön abtatet und ausgibt, welche Signale des neuen Datenpakets schon vorhanden sind. Beim schreiben (mit dem kompletten Skript) wird nur das letzte Signal des Franes berücksichtigt. Zeilenzuordnung ist auch richtig. schade, dass ich das ganze Zeug hier nicht hoch laden kann. Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 use OLE; use Win32::OLE::Const 'Microsoft excel'; use Cwd; my $directory = &getcwd; my $xlsfile = "$directory/Test_Auswertung_RX.xlsx"; #--Signalbeispiel des neuen Datenpaktes. In Spalte B durchsuchen--- my @array = ( 'TEMP_SCRA', 'ST_RMMI_SCRA', 'ST_RFG_SCRA', 'ST_FLLV_PU_SCRA', 'ST_FLLV_LEV_SCRA', 'RFLV_SCRA', 'RELA_MIX_SCRA', 'FLLV_SCRA', 'DISP_RQ_GR_GRB', 'DISP_PRG_GRB', 'DISP_PO_GRB', 'DISP_GR_GRB', 'ST_SYS_ERR_OBD_SCR', 'ST_ILK_SCRS', 'RQ_MIL_DIAG_OBD_SCR', 'AVL_PWR_EL_GEY', 'ST_DIAG_OBD_6_PT_MAX_MUX', 'ST_DIAG_OBD_6_PT_IMME_MUX', 'DIAG_ST_OBD_6_PT_8', 'DIAG_ST_OBD_6_PT_7', 'DIAG_ST_OBD_6_PT_6', 'DIAG_ST_OBD_6_PT_5', 'DIAG_ST_OBD_6_PT_4', 'DIAG_ST_OBD_6_PT_3', 'DIAG_ST_OBD_6_PT_2', 'DIAG_ST_OBD_6_PT_1', 'FLLUPT_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_OPMO_CHGE' ); #--Ende Signalbeispiel--- #---Main---------- open_excel(); #---Ende Main------- # ################################################################### # Sub Open excel File # ################################################################### sub open_excel { $excel = Win32::OLE->GetActiveObject('excel.Application')|| Win32::OLE->new('excel.Application'); my $workbook = $excel -> Workbooks -> Open ($xlsfile) or die ( "Can't open $xlsfile" ); $excel->{'Visible'} = 0; #0 is hidden, 1 is visible $excel->{DisplayAlerts}=0; #0 is hide alerts $sheet = $workbook -> Worksheets (1); $excel->{'Visible'} = 0; #0 is hidden, 1 is visible $excel->{DisplayAlerts}=0; #0 is hide alerts $sheet = $workbook -> Worksheets (1); # Find Last Row $LastRow = $sheet -> UsedRange -> Find({What => "*", SearchDirection => xlPrevious, SearchOrder => xlByRows}) -> {Row}; foreach (@array) { $Signal = $_; Search_Signal($Signal); } } $excel->{'Visible'} = 1; undef $workbook; undef $excel; sub Search_Signal { my ($In_file)= @_; for $row(16..$LastRow) { $col=2; my $name = $sheet -> Cells($row,$col) -> {'Value'}; if ($name eq $In_file) { print "Signal $In_file found on line $row\n"; $row++; } } } Anhänge |