Skip to content

ExcelWriter should support engine="xlsxwriter" #462

Closed
@Dr-Irv

Description

@Dr-Irv

Describe the bug
Need support engine="xlsxwriter" for ExcelWriter

To Reproduce

import pandas as pd

DF = pd.DataFrame({"a": [1, 2, 3], "b": [0.0, 0.0, 0.0]})

with pd.ExcelWriter("tmp.xlsx", mode="w", engine="xlsxwriter") as ew:
    DF.to_excel(ew, sheet_name="A")

pyright reports

ew.py
  c:\Code\pandas-stubs\ew.py:5:50 - error: Argument of type "Literal['xlsxwriter']" cannot be assigned to parameter "engine" of type "Literal['auto', 'openpyxl', 'pyxlsb', 'odf'] | None" in function "__init__"
    Type "Literal['xlsxwriter']" cannot be assigned to type "Literal['auto', 'openpyxl', 'pyxlsb', 'odf'] | None"
      Type cannot be assigned to type "None"
      "Literal['xlsxwriter']" cannot be assigned to type "Literal['auto']"
      "Literal['xlsxwriter']" cannot be assigned to type "Literal['openpyxl']"
      "Literal['xlsxwriter']" cannot be assigned to type "Literal['pyxlsb']"
      "Literal['xlsxwriter']" cannot be assigned to type "Literal['odf']" (reportGeneralTypeIssues)

Please complete the following information:

  • OS: Windows 10
  • python version: 3.9
  • version of type checker: pyright 1.1.283
  • version of installed pandas-stubs 1.5.2.221124

Additional context

Need to add "xlsxwriter" to:

engine: Literal["auto", "openpyxl", "pyxlsb", "odf"] | None = ...,

When creating a test, have to update pyproject.toml to install xlsxwriter for that test

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions