Klikací hyperlinky na soubory v ED_PODANI_DATA bez modrého podtržení
- Při generování reportu se vytvoří složka SOUBORY_PRO_FAKTURY_REPORT - KDAVKA → .txt, REQUEST → .xml, SERVERRESPONSE → .xml, PROTOCOL → .html - Buňky s obsahem jsou klikací (otevřou soubor v Notepadu/prohlížeči) - Font normální (černý, bez podtržení) – hyperlink funguje bez vizuální změny - Při každém spuštění se složka smaže a vygeneruje znovu čerstvá Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,13 @@ now = datetime.now()
|
|||||||
filename = now.strftime('%Y-%m-%d_%H-%M-%S') + '_faktury.xlsx'
|
filename = now.strftime('%Y-%m-%d_%H-%M-%S') + '_faktury.xlsx'
|
||||||
output_path = os.path.join(output_dir, filename)
|
output_path = os.path.join(output_dir, filename)
|
||||||
|
|
||||||
|
# --- Složka pro soubory (KDAVKA, REQUEST atd.) ---
|
||||||
|
files_dir = os.path.join(output_dir, 'SOUBORY_PRO_FAKTURY_REPORT')
|
||||||
|
import shutil
|
||||||
|
if os.path.exists(files_dir):
|
||||||
|
shutil.rmtree(files_dir)
|
||||||
|
os.makedirs(files_dir)
|
||||||
|
|
||||||
# --- Smazání předchozích verzí ---
|
# --- Smazání předchozích verzí ---
|
||||||
for f in os.listdir(output_dir):
|
for f in os.listdir(output_dir):
|
||||||
if f.endswith('_faktury.xlsx'):
|
if f.endswith('_faktury.xlsx'):
|
||||||
@@ -33,6 +40,7 @@ wb = openpyxl.Workbook()
|
|||||||
HEADER_FILL = PatternFill('solid', fgColor='2F5496')
|
HEADER_FILL = PatternFill('solid', fgColor='2F5496')
|
||||||
HEADER_FONT = Font(bold=True, color='FFFFFF')
|
HEADER_FONT = Font(bold=True, color='FFFFFF')
|
||||||
LINK_FONT = Font(color='0563C1', underline='single')
|
LINK_FONT = Font(color='0563C1', underline='single')
|
||||||
|
PLAIN_FONT = Font(color='000000') # normální font bez modrého podtržení
|
||||||
ZEBRA_FILL = PatternFill('solid', fgColor='DCE6F1')
|
ZEBRA_FILL = PatternFill('solid', fgColor='DCE6F1')
|
||||||
|
|
||||||
def style_header(ws):
|
def style_header(ws):
|
||||||
@@ -432,6 +440,37 @@ for i, row in enumerate(ed_data_rows, start=2):
|
|||||||
serverresp_txt = decode_latin_blob(serverresp, 'iso-8859-2')
|
serverresp_txt = decode_latin_blob(serverresp, 'iso-8859-2')
|
||||||
protocol_txt = decode_latin_blob(protocol, 'iso-8859-2')
|
protocol_txt = decode_latin_blob(protocol, 'iso-8859-2')
|
||||||
|
|
||||||
|
# Ulož soubory pro klikací hyperlinky
|
||||||
|
rel_prefix = 'SOUBORY_PRO_FAKTURY_REPORT'
|
||||||
|
kdavka_link = ''
|
||||||
|
request_link = ''
|
||||||
|
serverresp_link = ''
|
||||||
|
protocol_link = ''
|
||||||
|
|
||||||
|
if kdavka_txt:
|
||||||
|
fname = f'KDAVKA_{eid}.txt'
|
||||||
|
with open(os.path.join(files_dir, fname), 'w', encoding='utf-8') as f:
|
||||||
|
f.write(kdavka_txt)
|
||||||
|
kdavka_link = f'{rel_prefix}/{fname}'
|
||||||
|
|
||||||
|
if request_txt:
|
||||||
|
fname = f'REQUEST_{eid}.xml'
|
||||||
|
with open(os.path.join(files_dir, fname), 'w', encoding='utf-8') as f:
|
||||||
|
f.write(request_txt)
|
||||||
|
request_link = f'{rel_prefix}/{fname}'
|
||||||
|
|
||||||
|
if serverresp_txt:
|
||||||
|
fname = f'SERVERRESPONSE_{eid}.xml'
|
||||||
|
with open(os.path.join(files_dir, fname), 'w', encoding='utf-8') as f:
|
||||||
|
f.write(serverresp_txt)
|
||||||
|
serverresp_link = f'{rel_prefix}/{fname}'
|
||||||
|
|
||||||
|
if protocol_txt:
|
||||||
|
fname = f'PROTOCOL_{eid}.html'
|
||||||
|
with open(os.path.join(files_dir, fname), 'w', encoding='utf-8') as f:
|
||||||
|
f.write(protocol_txt)
|
||||||
|
protocol_link = f'{rel_prefix}/{fname}'
|
||||||
|
|
||||||
out = [
|
out = [
|
||||||
eid,
|
eid,
|
||||||
f"{hiccode} {HICCODE_MAP.get(str(hiccode), '')}" if hiccode else '',
|
f"{hiccode} {HICCODE_MAP.get(str(hiccode), '')}" if hiccode else '',
|
||||||
@@ -451,6 +490,14 @@ for i, row in enumerate(ed_data_rows, start=2):
|
|||||||
cell.alignment = WRAP
|
cell.alignment = WRAP
|
||||||
ws6.row_dimensions[i].height = 80
|
ws6.row_dimensions[i].height = 80
|
||||||
|
|
||||||
|
# Hyperlinky na soubory – F=KDAVKA, G=REQUEST, H=SERVERRESPONSE, I=PROTOCOL
|
||||||
|
for col_idx, link in [(6, kdavka_link), (7, request_link),
|
||||||
|
(8, serverresp_link), (9, protocol_link)]:
|
||||||
|
if link:
|
||||||
|
cell = ws6.cell(row=i, column=col_idx)
|
||||||
|
cell.hyperlink = link
|
||||||
|
cell.font = PLAIN_FONT # bez modrého podtržení
|
||||||
|
|
||||||
style_header(ws6)
|
style_header(ws6)
|
||||||
ws6.freeze_panes = 'A2'
|
ws6.freeze_panes = 'A2'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user