Konvertering af Excel til html
Microsofts office interop volder stadig mange problemer denne gang med Excel hvor jeg gerne skal kunne gemme xls filerne som html. Der opstår en fejl når jeg forsøger at åbne en xls fil, det vil den simpelthen ikke.her er min klasse:
using System;
using Exceli = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
namespace wordpdfcllasses
{
/// <summary>
/// Summary description for Excel.
/// </summary>
public class Excel
{
private Exceli.ApplicationClass app = new Exceli.ApplicationClass();
private object missingValue = Type.Missing;
private string sourceDirectory;
private string sourceFilename;
private string completeSource;
private string destinationFilename;
private object format;
public Excel()
{
sourceDirectory = "c:";
sourceFilename = "kursus.xls";
completeSource = sourceDirectory + "\\" + sourceFilename;
destinationFilename = "c:\\kursus.html";
format = Exceli.XlFileFormat.xlHtml;
}
public void konverterTilHtml()
{
app.Workbooks.Open(completeSource,
missingValue, missingValue, missingValue,
missingValue, missingValue, missingValue,
missingValue, missingValue, missingValue,
missingValue, missingValue, missingValue,
missingValue, missingValue);
app.ActiveWorkbook.SaveAs(
destinationFilename, format, missingValue,
missingValue, missingValue, missingValue,
Exceli.XlSaveAsAccessMode.xlNoChange, missingValue,
missingValue, missingValue, missingValue, missingValue);
app.Quit();
}
public string sourceD
{
get
{
return sourceDirectory;
}
set
{
sourceDirectory = value;
completeSource = sourceDirectory + "\\" + sourceFilename;
}
}
public string sourceFN
{
get
{
return sourceFilename;
}
set
{
sourceFilename = value;
completeSource = sourceDirectory + "\\" + sourceFilename;
}
}
public string getCompleteSource
{
get
{
return completeSource;
}
}
public string Destination
{
get
{
return destinationFilename;
}
set
{
destinationFilename = value;
}
}
}
}