import pandas as pd

# Read HTML content (assuming it contains a table)
html_content = """
<html>
<head>
<style>
  table {
      margin-left: 20px; /* Add margin to the left */
          border-collapse: collapse; /* Ensure proper border styling */
            }
              th, td {
                  border: 1px solid black;
                      padding: 8px;
                          text-align: center;
                            }
                            </style>
                            </head>
                            <body>
                            <table border="1" class="dataframe">
                              <thead>
                                  <tr style="text-align: center;">
                                        <th>Column1</th>
                                              <th>Column2</th>
                                                    <th>Column3</th>
                                                          <!-- Add more columns based on your DataFrame -->
                                                              </tr>
                                                                </thead>
                                                                  <tbody>
                                                                      <tr>
                                                                            <td>Value1</td>
                                                                                  <td>Value2</td>
                                                                                        <td>Value3</td>
                                                                                              <!-- Add rows dynamically based on your DataFrame -->
                                                                                                  </tr>
                                                                                                      <tr>
                                                                                                            <td>ValueA</td>
                                                                                                                  <td>ValueB</td>
                                                                                                                        <td>ValueC</td>
                                                                                                                            </tr>
                                                                                                                              </tbody>
                                                                                                                              </table>
                                                                                                                              </body>
                                                                                                                              </html>

"""

# Parse HTML table into a DataFrame
dfs = pd.read_html(html_content)
df = dfs[0]  # Assuming the first table is the one we need

# Save DataFrame to Excel
output_path = "output.xlsx"
df.to_excel(output_path, index=False)
print(f"File saved as {output_path}")
