Forum Discussion

Alen1987's avatar
Alen1987
Frequent Visitor
3 years ago

Get xlsx file from website

Hi guys,
I am trying to find solution how can i link external data source to PBI .
In my case my data is .xlsx file located on web page, and i have several of them.
So basically i need get excel files from web pulled in to PBI and have it automated, because this files refresh each day.
i have this (did use custom name to protect source
web page - name.something.com/admin

file1_2023-01.xlsx
file1_2023-02.xlsx
file1_2023-03.xlsx
file1_2023-04.xlsx
file1_2023-05.xlsx

 

5 Replies

  • That is sub optimal.  Would have been better if they Excel files were on a Sharepoint.

     

    Can you do a folder contents listing on that web site, or do you know when which files appear?

    • Alen1987's avatar
      Alen1987
      Frequent Visitor

      Hi
      Thank you for reply.
      Data refreshes each day (mostly).
      I was thinking using web scraping tool or something simillar. 
      Basicly, i would like to automate it if possible. 
      Automaticly download files to folder (sharepoing or local) and then PBI pulls them.

      • lbendlin's avatar
        lbendlin
        Icon for Super User rankSuper User

        Talk to the website owner, maybe they can allow directory browsing for that folder.

  • Johns23's avatar
    Johns23
    Regular Visitor

    To link an external data source, such as an Excel file located on a web page, to Power BI, you can follow these steps:

    Open Power BI Desktop and select "Get Data" from the Home tab.

    In the "Get Data" window, select "Web" from the list of available data sources.

    In the "From Web" window, enter the URL of the web page where your Excel files are located and click "OK".

    Power BI will retrieve the web page and display a Navigator window that shows the available files on the web page.

    Select the Excel file you want to connect to and click "Load" to import the data into Power BI.

    If you want to automate the process, you can create a query that pulls data from the web page and refreshes it on a regular schedule. To do this, click "Edit" in the "Navigator" window and create a new query using the "Transform Data" window.

    Once you have created the query, you can schedule a refresh using the "Refresh" button on the Home tab. Click "Refresh Now" to refresh the data immediately, or select "Schedule Refresh" to set up a regular refresh schedule.

    Note that if your Excel files are password-protected or require authentication, you may need to provide additional credentials in order to access them. Also, be aware that Power BI may have some limitations on the amount of data that can be imported from a web source.

  • import pandas as pd
    from openpyxl import Workbook
    from openpyxl.styles import PatternFill, Font, Alignment

    # Data for February 2026
    days = list(range(1, 29))
    nombres_dias = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] * 4
    holidays = [16, 17] # Carnival

    # Definition of tabs and personal based on user files
    Sectors = {
    "TBAR-RECO-DEMSA-QUAL-PADI": ["BARRIOS", "MENDOZA", "VERA", "DIAZ J", "AGUIRRE", "GIMENEZ", "PEREYRA J", "RUIZ DIAZ", "TORRES", "GOMEZ C", "PARED"],
    "ZAP-BREN-CBUS-PLIZ-EIT-HOL": ["VILLALBA G", "ORTEGA", "ROMERO", "SOSA E", "DIAZ S", "ROMERO S", "CABRERA"],
    "CELU-SINEA-ASTILL-PPANAL-ALZ": ["PUEBLA", "SALAS", "MEDINA", "CÁCERES", "BRITOS", "LEDESMA"],
    "GREIF-NETA-SINTER-BCA-COV": ["ZURITA", "VILLALBA", "TEVEZ", "VAZQUEZ", "SILVA", "CORREA"],
    "ASPEN-YAGUAR-CERRONEGRO": ["PEREZ LORENA", "DIAZ PATRICIO", "NAVARRO", "ARRIOLA", "PEREZ RAUL"],
    "CHACRAS - SHELL": ["FLORES ADRIÁN", "LEGUIZAMÓN G.", "GONZÁLEZ JORGE", "DURAND NICOLÁS"],
    "SUPERV-MONITORING": ["ALBORNOZ"],
    "MISCELLANEOUS": ["CONTINGENT STAFF 1", "CONTINGENT STAFF 2"] # Structure-based placeholder
    }

    # Crear el Excel
    file_path = "/mnt/data/FEBRERO_2026_Planilla_Turnos.xlsx"
    wb = Workbook()
    wb.remove(wb.active) # Quitar hoja por defecto

    # Estilos
    fill_fin_semana = PatternFill(start_color="FFEB9C", end_color="FFEB9C", fill_type="solid") # Amarillo claro
    fill_feriado = PatternFill(start_color="FFC7CE", end_color="FFC7CE", fill_type="solid") # Rojo claro
    header_font = Font(bold=True)
    center_align = Alignment(horizontal="center")

    for nombre_hoja, personal in sectores.items():
    ws = wb.create_sheet(title=nombre_hoja[:31]) # Excel character limit

    # Day Headers
    ws.cell(row=1, column=1, value="PERSONAL")
    For i, dia in enumerate(dias):
    col = i + 2
    cell_dia = ws.cell(row=1, column=col, value=day)
    cell_nom = ws.cell(row=2, column=col, value=nombres_dias[i])

    # Apply formatting to weekends (Sun is i=0, 7, 14, 21 / Sat is i=6, 13, 20, 27)
    if nombres_dias[i] in ["Sat", "Sun"]:
    cell_dia.fill = fill_fin_semana
    cell_nom.fill = fill_fin_semana

    # Format holidays
    If day on holidays:
    cell_dia.fill = fill_feriado
    cell_nom.fill = fill_feriado
    cell_dia.value = f"{day} (F)"

    # Cargar Personal
    for row_idx, nombre in enumerate(personal, start=3):
    ws.cell(row=row_idx, column=1, value=nombre)
    # Pintar celdas de fin de semana para el personal
    for col_idx, dia in enumerate(dias, start=2):
    if nombres_dias[col_idx-2] in ["Sab", "Dom"]:
    ws.cell(row=row_idx, column=col_idx).fill = fill_fin_semana
    if dia in feriados:
    ws.cell(row=row_idx, column=col_idx).fill = fill_feriado

    wb.save(file_path)