Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8773953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:26:19+00:00 2026-06-13T18:26:19+00:00

I wanted to know if there is a way I can get the content

  • 0

I wanted to know if there is a way I can get the content of a Web Browser control and save it in a format that would open in Excel? Currently I have an application that gets data from the user and converts it to a table and displays it in html in a WPF Web Browser control. I can export this controls content successfully as a PDF document as follows:

string fileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".html";

File.WriteAllText(fileName, generateHtml());

//Creates a new instance of the Microsoft office interop for using MS Word
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
app.Visible = false;
Microsoft.Office.Interop.Word.Document doc = app.Documents.Open(fileName);
doc.SaveAs("C:\\Temp\\testExport.pdf", 17);
app.Quit();

This works fine for exporting a PDF file, the issue I am having is that I can’t for the life of me get this to work with an excel file. So far I am trying to do it like so:

  string filePath = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".html";

  File.WriteAllText(filePath, generateHtml());

  //Creates a new instance of Microsoft office interop for using MS Excel
  Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
  //Create a new instance of a workbook
  Microsoft.Office.Interop.Excel.Workbook excelWorkBook = excelApp.Workbooks.Add();
  //Don't Show MS Excel
  excelApp.Visible = false;
  //Open a file at location
  Microsoft.Office.Interop.Excel.Workbook excelWorkBook2 = excelApp.Workbooks.Open(filePath);
  //Convert that file to an XLSX document
  excelWorkBook2.SaveAs("C:\\Temp\\testExport.xlsx", Microsoft.Office.Interop.Excel.XlFileFormat.xlXMLSpreadsheet, Missing.Value, Missing.Value, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlUserResolution, true, Missing.Value, Missing.Value, Missing.Value);
  //Close excel
  excelApp.Quit();

However when I try and open the file that this generates I get the following error:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:26:20+00:00Added an answer on June 13, 2026 at 6:26 pm

    Have you tried changing the filename to .xls? I believe that Microsoft.Office.Interop.Excel.XlFileFormat.xlXMLSpreadsheet exports to xls, not xlsx

    All the types can be found here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to know if there's a way I can bind an Asp.net Ajax
I wanted to know if there is a way or ways to get the
I wanted to know if there is a way to get all the Entities
I wanted to know if there is a way to get in a One2Many
I wanted to know if there is way to log the mysql queries in
Wanted to know if there was a way one could query shelveset details from
I wanted to know if there is any way to synchronize (or exchanging files)
I just wanted to know if there is a way on how to remove
hi guys I wanted to know, is there a way to not display my
Is there a way in iOS app programming that I can make an user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.