office-interop

PPTX to Image conversion doesn't work on windows server 2012 production

醉酒当歌 提交于 2019-12-02 14:44:27
问题 We have requirement to convert uploaded PPT or PPTX files into image files. We developed this working locally with following (POC code): Application pptApplication = new Application(); Microsoft.Office.Interop.PowerPoint.Presentation pptPresentation = pptApplication.Presentations.Open2007(filePath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse); List<string> files = new List<string>(); for (int i = 1; i <= pptPresentation.Slides.Count; i++) { pptPresentation.SaveCopyAs

DateTime.Now.ToString(“MM/DD/YYYY”) contains incorrect month

怎甘沉沦 提交于 2019-12-02 13:05:35
So I have been adding a DateTime.Now.ToString("MM/DD/YYYY") to a List (along with a bunch of other data) and the later writing these lists to individual rows in an Excel workbook. This all works great (it's something I do regularly), except, the month. I have tried exporting it three times and each time I get a different month; the first time 56/26-17, the second 2/26/2017, and the third 14/26/2017.... Use this instead: DateTime.Now.ToString("MM/dd/yyyy") "MM" for month. "dd" for days. "yyyy" for year. "MM/DD/YYYY" is wrong format: Console.WriteLine(DateTime.Now.ToString("MM/DD/YYYY")) //

How can I check the version of Excel files in C#?

╄→尐↘猪︶ㄣ 提交于 2019-12-02 13:03:13
问题 I need to differentiate that a selected file is created with Excel 2010 or Excel 2013 version of a selected Excel file and Excel application on server must match in order to continue. I can get the server's Excel application version: xApp = new Microsoft.Office.Interop.Excel.Application(); // getting version of Server's Excel Application string versionName = xApp.Version; int length = versionName.IndexOf('.'); versionName = versionName.Substring(0, length); object missing = Type.Missing;

How to open Excel file with Read Only protection?

倾然丶 夕夏残阳落幕 提交于 2019-12-02 11:51:55
问题 I have opened Excel file in my C# WinForm Application adding reference to Microsoft.Office.Interop.Excel.dll and using DSO FRAMER CONTROL. But i want to open my excel file with read only protection.I have successfully done this for WORD Application like this Word.Document wordDoc = (Word.Document)axFramerControl1.ActiveDocument; Word.Application wordApp = wordDoc.Application; wordDoc.Protect(Word.WdProtectionType.wdAllowOnlyReading); In the same i want to do this work for Excel.But i couldn't

How do I merge multiple excel files to a single excel file

旧时模样 提交于 2019-12-02 11:43:38
So I was trying to make an excel sheet aggregator. In my line of work we get people who send us a bunch of individual excel files that are all related each with only 1 sheet used. I was following to some degree this previous post's ideas . But upon doing so, some of the excel sheets I copied were coming up blank. Only certain ones. I have no idea why some are blank and others are fine. Here is the code I use to open and copy the excel files OpenFileDialog browse = new OpenFileDialog(); browse.Multiselect = true; DialogResult result = browse.ShowDialog(); if (result == DialogResult.OK) try /

How to make this custom worksheet initialization faster?

江枫思渺然 提交于 2019-12-02 09:07:54
Summary This question is somehow the follow-up to this question: How to implement column self-naming from its index? Having tested the code provided in this above-linked question's answers, I finally encountered a serious performance issue. Performance issue The performance issue occurs upon a Sheet initialization, that is, when I initialize the Sheet's Cells. ''' <summary> ''' Initialize an instance of the Company.Project.Sheet class. ''' </summary> ''' <param name="nativeSheet">The native worksheet from which to initialize.</param> Friend Sub New(ByVal nativeSheet As Microsoft.Office.Interop

How to open Excel-workbooks without the message The workbook contains links to other data sources. programmatically?

做~自己de王妃 提交于 2019-12-02 08:33:07
I want to open 1 or more Excel-workbooks programmatically. And when I open the workbook, you get a question: The workbook contains links to other data sources. And I don't want press " Don't update " How can you leave this messagebox? So the functionality will not interrupted anymore. Updating is not needed. try placing in the workbook Open event handler: Application.AskToUpdateLinks = False I don't think you can get around the dialogs with the excel interop libraries (the warnings are there for a reason). The way I've always done this in the past is to treat the Excel file like it's a

Formatting a plain text e-mail in C#

两盒软妹~` 提交于 2019-12-02 08:23:20
I am trying to print a table inside an e-mail using plain text. I have the following code: string body = string.Format("{0,-30}{1,-30}{2,-50}{3,-40}", "Col1", "Col2", "Col2", “Col4”); body += string.Format("{0,-30}{1,-30}{2,-50}{3,-40}", value1, value2, value3, value4); Microsoft.Office.Interop.Outlook.ApplicationClass myOutlookApplication = null; myOutlookApplication = new Microsoft.Office.Interop.Outlook.ApplicationClass(); Microsoft.Office.Interop.Outlook.MailItem myNewMail = (Microsoft.Office.Interop.Outlook.MailItem)myOutlookApplication.CreateItem( Microsoft.Office.Interop.Outlook

Auto Break between Checkbox and Text in C#

喜你入骨 提交于 2019-12-02 07:40:50
问题 I hope you can help me with my problem. I want to automatically generate a Word checklist with a C# program. But I can't get it to put the text behind the checkbox. The text always lands in a new line under the checkbox. How can I solve this problem? You know some other functions? public void createChecklist() { Application app = new Application(); app.Visible = true; Document doc = app.Documents.Add(); Paragraph para = doc.Paragraphs.Add(); ContentControl checkbox = para.Range

How to open Excel file with Read Only protection?

一个人想着一个人 提交于 2019-12-02 07:02:19
I have opened Excel file in my C# WinForm Application adding reference to Microsoft.Office.Interop.Excel.dll and using DSO FRAMER CONTROL. But i want to open my excel file with read only protection.I have successfully done this for WORD Application like this Word.Document wordDoc = (Word.Document)axFramerControl1.ActiveDocument; Word.Application wordApp = wordDoc.Application; wordDoc.Protect(Word.WdProtectionType.wdAllowOnlyReading); In the same i want to do this work for Excel.But i couldn't able to protect Excel file on that way. string path = "C:\\test-wb.xlsx"; axFramerControl1.Open(path,