I working on the Excel in the server and when I trying to open my Excel file with Microsoft.Office.Interop.Excel, I have this error:
Exception de HRESULT : 0x800A03EC
I check my access to my file, and my IIS account have a full control on this. This is my code :
var excelApp = new Excel.Application();
Excel.Workbook workbook = excelApp.Workbooks.Open(
Filepath,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing,
true
);
Thanks
Related
I was wondering if someone can assist me in achieving the C# code below in either EPPlus or OpenOffice XML:
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
string excelFileName = "Sample.xlsx";
string currentDirectory = Directory.GetCurrentDirectory();
string excelFilePath = System.IO.Path.Combine(currentDirectory, excelFileName);
app.Workbooks.Open(excelFilePath,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
string xmlContent = string.Empty;
// Use the map (XSD inside the Excel file)
app.ActiveWorkbook.XmlMaps[1].ExportXml(out xmlContent);
app.Workbooks.Close();
Using Microsoft.Office.Interop.Excel.Application requires installation of Microsoft Office on the server. Is there any way around this other than installing Microsoft Engine?. Basically how to read XMLMap without office.Interop?
Thank you
I have a word document which I pass to a function that super script everything between two "£"'s. The problem is that if I don't have enabled English setting on my computer there will display a error (in swedish) complaining about the matching. I guess it has something to do with this particular line doc.Find.Text = "£([A-Z]{1,5})£"; since the document also contains letter å,ä and ö. However I can't get it to work no matter what I try, I'm really stuck. I'm not an Interop expert so if anyone could help me out I would appreciate it a lot!
public void SuperScript(Word.Range doc)
{
doc.Find.Replacement.Font.Superscript = 1;
doc.Find.MatchWildcards = true;
doc.Find.Text = "£([0-9]{1,5})£";
doc.Find.Replacement.Text = #"\1";
doc.Find.Execute(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Word.WdReplace.wdReplaceAll, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
doc.Find.Text = "£([A-Z]{1,5})£";
doc.Find.Replacement.Text = #"\1";
doc.Find.Execute(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Word.WdReplace.wdReplaceAll, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
doc.Find.Text = "£([a-z]{1,5})£";
doc.Find.Replacement.Text = #"\1";
doc.Find.Execute(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Word.WdReplace.wdReplaceAll, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
I'm just guessing... Hope this is an answer for you...
You could do Something like that "£(\w[^0-9]{1,5})£" or "£(\D{1,5})£ excluding numbers. If you don't care about the type of characters returned, you could just do "£(.{1,5})£"
I am opening an existing Excel file with following process:
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
excel.Visible = true;
Workbook w = excel.Workbooks.Open(#"E:\ishu\Test.xlsx"
, Type.Missing,
true, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Type.Missing);
Worksheet ws = (Worksheet)w.Worksheets[1];
Microsoft.Office.Interop.Excel.Range xlRange = ws.UsedRange;
excel.Visible = true;
Excel process gets started in task manager but no Excel window get visible.
This probably isn't the answer you are looking for, but my application uses
System.Diagnostics.Process.Start(ExcelFileToOpen);
The above is run only when the Excel file exists.
I am trying to print a Microsoft Excel document in C# using visual studio and I get a Show method of Dialog class failed exception every time I attempt to execute this piece of code:
bool userDidntCancel =
ExcelApp.Dialogs[Excel.XlBuiltInDialog.xlDialogPrint].Show(
Type.Missing, Type.Missing, Type.Missing, Type.Missing,Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Here is the full code I'm using:
Excel.Application ExcelApp = new Excel.Application();
Excel.Workbook wb = ExcelApp.Workbooks.Open(
PATH,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Excel.Worksheet ws = (Excel.Worksheet)wb.Worksheets[1];
try
{
bool userDidntCancel =
ExcelApp.Dialogs[Excel.XlBuiltInDialog.xlDialogPrint].Show(
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
catch
{
ExcelApp.Quit();
File.Delete("Container Status.xls");
}
Is there something I'm missing?
I'm trying to export an excel sheet into xml spread sheet 2003 in order to apply some xsl on the result xml file ,
so , i have tried to save the sheet i'm working on using XlFormat enum as follows :
Excel.Application app = new Excel.Application();
Excel.Workbook workbook;
Excel.Worksheet NwSheet;
workbook = app.Workbooks.Open(#"C:\file.xlsx",
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing);
NwSheet = (Excel.Worksheet)workbook.Sheets.get_Item(1);
string outfile = #"c:\temp.xml";
NwSheet.SaveAs(outfile, Excel.XlFileFormat.xlXMLSpreadsheet, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
This code generated an xml file with the following problems :
1-cells of type date are generated as :
2011-10-10T00:00:00.000 , i want it to be 10/10/2011 exactly as it was in the excel sheet so how can i access to these cell's types in order to change them ??
2-numbers as 8.2 were generated as 8.1999999999999993 why did that happen and how can i get it just as is it in the excel sheet
i guess both are faces of the same problem , i just need the data as it appears in the excel sheet.