Importera matris från Excel



"""
Programmet importerar matris från Excel
"""


import numpy as np
import openpyxl as op


def matrix_from_excel(rows: int, columns: int, filename: str):
    wb_in = op.load_workbook(filename=filename)
    sheet = wb_in.active
    matrix = np.zeros([rows, columns])
    for i in range(1, rows + 1):
        for j in range(1, columns + 1):
            matrix[i-1, j-1] = sheet.cell(row=i, column=j).value
    wb_in.close()
    return matrix

print(matrix_from_excel(5, 5, './indata.xlsx'))