# Read Excel file from Perspective upload component

**URL:** <https://forum.inductiveautomation.com/t/read-excel-file-from-perspective-upload-component/88888>\
**Category:** Ignition\
**Tags:** ignition81, perspective, scripting\
**Created:** [April 16, 2024, 1:32pm UTC](https://forum.inductiveautomation.com/t/read-excel-file-from-perspective-upload-component/88888 "2024-04-16T13:32:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakned](https://avatars.discourse-cdn.com/v4/letter/j/4da419/32.png) [@jakned](https://forum.inductiveautomation.com/u/jakned)\
**Post date:** [April 16, 2024, 1:32pm UTC](https://forum.inductiveautomation.com/t/read-excel-file-from-perspective-upload-component/88888/1 "2024-04-16T13:32:19Z")

</div>

Hi, based on other thread on this forum, I tried to implement excel reading capabilities to my project. Below is a part of my code which works fine:

```auto
def get_workbook(file_path):
    # type: (str) -> Workbook
    """Get workbook from specified location."""
    file_stream = None

    try:
        file_stream = FileInputStream(file_path)
        workbook = WorkbookFactory.create(file_stream)
        return Workbook(workbook)

    finally:
        if file_stream is not None:
            file_stream.close()

```

In this case, I am reading a file from my PC. My project requires user to upload the file using the Perspective upload component which then provides the file as bytes.  
How should I take those bytes and create a Workbook from it?

I tried reading the file as bytes in script console like this:

```auto
bytes = system.file.readFileAsBytes(path)
wb = WorkbookFactory.create(bytes)

```

Which does not work and I am not surprised.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 16, 2024, 2:35pm UTC](https://forum.inductiveautomation.com/t/read-excel-file-from-perspective-upload-component/88888/2 "2024-04-16T14:35:53Z")

</div>

Wrap the bytes in a java `ByteArrayInputStream`. That can be fed to `.create()` just like a file stream.
