ASP. NET converts Word documents to pdf. asp. netpdf
This article describes how ASP. NET converts a Word document to a pdf file. The specific implementation steps are as follows:
1. Add referenceCopy codeThe Code is as follows: using Microsoft. Office. Interop. Word;Ii. Conversion Method1. Method
Copy codeThe Code is as follows: // /// Convert a Word file into a PDF file/// /// /// /// Public static bool WordToPdf (string sourcePath, string targetPath
CodeYou have already tested it. Add the try catch Statement by yourself. Remember to release the resource after an error occurs.
After this operation is performed, the operated tag will be removed.
Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> Private Void Button#click ( Object Sender, eventargs E) {Clearbookmarkfromdoc (@"C: \ test.doc","A");} Public Void Clearbookmarkfromdoc ( String Filepath, String Bkname
In. Net 4.0 CTP, the most notable improvement of InterOP is type equivalency, which is also called no Pia. Before introducing how to use this new feature, I think we should start from the history to explore what we actually want to solve and what solutions we used in the past, and the problems with these methods.
In. net, to access COM objects, You need to define a series of hosted interfaces, struct, and class. With the typelibrary, you can use tlbim
From http://www.codeproject.com/KB/grid/ExcelAdapter.aspx
On the recent project I worked on, I had a requirement to load data from an Excel spreadsheet to a database on a regular basis. my goal was to load the data from Excel to a ADO. net dataset and run my business rules. I couldn't find any articles addressing this problem and so I decided to write one.
There are two projects added in the source code package.
ExceladoadapterBuilds the library,Exceladoadapter. dll.
Exceladapterte
Is to use WPF to export data into Excel and other. NET applications are the same, Asp. both net and winform are implemented in the same way. The only difference is ASP.. NET may have user permissions. After all, Asp.. Net execution users are specified by IIS, rather than default system users.
The specific implementation method is as follows,CodeUsing a complete namespace for ease of understanding
Step 1: Do not reference ExcelProgramSet, different from other onlineArticle, I directly r
C: \ ProgramFiles \ microsoftvisual studio. Net \ frameworksdk \ samples \ technologies \ InterOP \ platforminvoke \ winapis \ CS directory contains a large number of examples of calling APIs.
I. Call format
Using system. runtime. interopservices; // reference this namespace to simplifyCode
// Use the dllimportattribute feature to introduce API functions. Note that empty methods are declared, that is, the method body is empty.
[Dllimport ("use
In recent weeks, with the activation of the Open Networking Foundation (ONF) and the announcement of support for almost all mainstream network providers, the OpenFlow specification broke out in the network field. In fact, the OpenFlow switch has been published on Interop Las Vegas 2011 and has aroused great controversy.
SDN allows network engineers to control and manage their networks so that they can better serve their respective needs, thereby incre
C # the main method for exporting Excel is as follows:Code:Public void CellToCell (DataSet ds){# Region required objects for instantiation// Instantiate an Excel Document ObjectMicrosoft. Office. Interop. Excel. Application exapp = new Microsoft. Office. Interop. Excel. Application ();// Set visible// If the value is false, the Excel document cannot be viewed.Exapp. Visible = true;// Set the workbook format
======================= try
27 .{
28. using (StreamWriter sw = new StreamWriter ("Storage path and Page name", false, System. Text. Encoding. GetEncoding ("GB2312 ")))
29 .{
30. sw. WriteLine (htmltext );
31. sw. Flush ();
32. sw. Close ();
33.} catch {Response. Write ("The file cocould not be wirte :");}Copy the code summary:This method can be used to easily generate html files. The program uses cyclic replacement, so it is very fast for templates that need to replace a large number of element
, create a process to set the table title format, and then add the adddata method to create a Word Table and set its format. Set the table title format
Create a method in the actionscontrol class to set the table title format.
Static VoidSetheadings (Microsoft. Office. InterOP. Word. Cell tblcell,StringText){Tblcell. range. Text = text;Tblcell. range. Font. Bold = 1;Tblcell. range. paragraphformat. Alignment =Microsoft. Office.
Public void CellToCell (DataSet ds){# Region required objects for instantiation// Instantiate an Excel Document ObjectMicrosoft. Office. Interop. Excel. Application exapp = new Microsoft. Office. Interop. Excel. Application ();// Set visible// If the value is false, the Excel document cannot be viewed.Exapp. Visible = true;// Set the workbook formatMicrosoft. Office. In
Word object model:
Application Object
The Application Object indicates the word application, which is the parent of all other objects. All its members are generally applied to word as a whole. You can use the attributes and methods of this object to control the word environment.
Document Object
Microsoft. Office. InterOP. Word. Document objects are the hub of word programming. When you open a document or create a new document, a new Microsoft. Offic
C # after Microsoft. Office. Core is referenced in the projectMicrosoft. Office. Core. msotristate, Still error:
Error 1 type"Microsoft. Office. Core. msotristate"InCentralized definition of referenced programs. You must add a reference to the assembly "office, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c. C:/documents and
Error 2: Microsoft. Office. InterOP. PowerPoint. Presentations. Open (string,Microsoft. Office. Core.
Problem description
1. Number of records generated by each sheet in Excel
2. Asp.net highlights some EXCEL export problems
3. Download failed. The temporary file or its disk cannot be written.
4. Failed to Load file or assembly "Microsoft. Office. InterOP. Excel, version = 14.0.0.0 ,**
5. An error of {00024500-00 *** occurs when an excel program is released under IIS.
6. system. componentmodel. win32exception: Access Denied
A detailed explanation of t
Fp2003/owc11.msi
Reference
Microsoft Office Web Components 11.0
C:/program files/common files/Microsoft shared/Web Components/11/owc11.dll
Installation File office2003 installation CD/fp2003/owc11.msiOffice2003 CD/office11/owc11.msi
After office2003 is installed by default, I don't know if it was installed before. After installation, I can find this component in the studio2005 system.
However, this component is still unavailable in ASP.
'Check whether the component is supported and the subroutin
C # Import and Export (Excel) data
Today I got an example of importing and exporting Excel Data. First, the namespace should reference Microsoft. Office. InterOP. Excel and system. Io. The following is my code (for reference only ):
Using system;Using system. Collections. Generic;Using system. componentmodel;Using system. Data;Using system. drawing;Using system. LINQ;Using system. text;Using system. Windows. forms;Using Microsoft. Office.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.