def find_exact_excel_cell(file_path, sheet_name, left_px, top_px): """ Converts image pixel position (left_px, top_px) into the closest Excel cell. Uses accurate width and height calculations. """ app = xw.App(visible=False) # Prevent Excel UI from opening wb = xw.Book(file_path) ws = wb.sheets[sheet_name]
x_offset = 0 # Tracks total width in pixels y_offset = 0 # Tracks total height in pixels
target_col = None target_row = None
# Retrieve total columns and rows total_cols = ws.used_range.columns.count total_rows = ws.used_range.rows.count
# Find the closest column (X position) for col in range(1, total_cols + 1): # xlwings uses 1-based index col_letter = get_column_letter(col) # Convert to 'A', 'B', etc. col_width = ws.range(f"{col_letter}1").column_width col_pixel_width = column_width_to_pixels(col_width) # Convert width to pixels
if x_offset app = xw.App(visible=False) # Open the Excel workbook wb = app.books.open(file_name)
sheet = wb.sheets[0] sheet.page_setup.zoom = 100 # Ensure no zooming sheet.page_setup.print_quality = 300 img_file = os.path.join(output_path, f"{name_no_extention}.png") end_range = spreadsheet_max_dimensions(file_name, sheet.name) custom_range = f"A1:{end_range}" # Change this to your desired range sheet.range(custom_range).to_png(img_file) [/code]
Ich muss eine Tabelle in PDF mit EasyTable oder Boxable erstellen. Der Zellinhalt ist Text mit Latein- und Mandarincharakter. Aber ich kann keine Dokumentation finden, um dies zu tun.
Dies ist das...
Ich arbeite an einem POC, in dem der Fall die vorhandene Produktionsdatenbank -Abfrage (ACL) in die Datenbankabfrage konvertieren soll. Unser Client ändert die gesamte Datenbankproduktion in...
Wir würden PDFs aus Excel über Python generieren. Wir tun dies derzeit mithilfe der Win32com-Bibliothek gemäß dieser Stack Overflow-Antwort. Zusammenfassend rufen wir explizit o =...