Office OCX - Word OCX, Excel OCX, PowerPoint OCX

> Esempio di Edraw > Office OCX - Word OCX, Excel OCX, PowerPoint OCX
foto di autore
Manuela Piccola | 2023-03-20 14:55:22
La scelta migliore per fare hosting di file Word, Excel e PowerPoint con la tecnologia Office OCX.

Con l'avvento del Componente di Visualizzazione Office di Edraw, creare applicazioni Office che interagiscono con l'automazione di office è più semplice che mai.

Office OCX

Clicca qui per scaricare Office OCX - Supporta Word, Excel, PowerPoint, Visio e Project

download gratuito5 MB

I seguenti codici descrivono un approccio per visualizzare la finestra di MS office dentro un modulo in c#.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace edofficedemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void CreateWord_Click(object sender, EventArgs e)
{
axEDOffice1.CreateNew("Word.Application");
}
private void CreateExcel_Click(object sender, EventArgs e)
{
axEDOffice1.CreateNew("Excel.Application");
}
private void CreatePpt_Click(object sender, EventArgs e)
{
axEDOffice1.CreateNew("PowerPoint.Application");
}
private void Open_Click(object sender, EventArgs e)
{
axEDOffice1.OpenFileDialog();
}
private void SaveAs_Click(object sender, EventArgs e)
{
axEDOffice1.SaveFileDialog();
}
private void Protect_Click(object sender, EventArgs e)
{
if(axEDOffice1.GetCurrentProgID() == "Word.Application")
{
axEDOffice1.ProtectDoc(2);//wdAllowOnlyFormFields
}
else if(axEDOffice1.GetCurrentProgID() == "Excel.Application")
{
axEDOffice1.ProtectDoc(0);//XlProtectTypeNormal
}
}
private void CancelProtect_Click(object sender, EventArgs e)
{
if (axEDOffice1.IsOpened())
{
axEDOffice1.UnProtectDoc();
}
}
private void CloseDoc_Click(object sender, EventArgs e)
{
if(axEDOffice1.IsOpened())
{
axEDOffice1.ExitOfficeApp();
}
}
private void PrintDoc_Click(object sender, EventArgs e)
{
if (axEDOffice1.IsOpened())
{
axEDOffice1.PrintDialog();
}
}
private void PrintPreview_Click(object sender, EventArgs e)
{
if (axEDOffice1.IsOpened())
{
axEDOffice1.PrintPreview();
}
}
private void btnAbout_Click(object sender, EventArgs e)
{
axEDOffice1.AboutBox();
}
private void Form1_Resize(object sender, EventArgs e)
{
Control control = (Control)sender;
axEDOffice1.SetComponentSize(control.Size.Width-32, control.Size.Height-130);
}
}
}

Office OCX può essere usato con qualsiasi linguaggio di programmazione che supporta il controllo ActiveX come C#, WPF, Delphi, Perl, VB, VB.NET, ASP.NET, PHP, JSP e HTML. Il componente supporta l'integrazione perfetta con Office 97, Office 2000, Office 2003, Office 2007 e Office 2010.

Fai Automazione Office in C#

Mostra/Nascondi la Barra dei Menu di Office