Wie ein Microsoft Excel (.xlsx) zu einer PPTProgrammatically (C#) konvertieren Excel in eine Liste von Bild
Mein bestimmt
AlgorithmusDatei konvertieren Get Charts in Excel programmatisch (C#) Datei . und speichern Sie in Liste der Bilder
Derzeit bin ich mit Microsoft Interop Bibliotheken, auch durch ich nicht, wie ich habe keine freie Alternative für diese Aufgabe
Also meine aktuelle Arbeit-around ist wie folgt:
Öffnen Sie Excel-Datei mit Microsoft Interop;
Alle Charts in Excel
Verwenden Copypicture() auf diesem Diagramm, das die Daten in die Zwischenablage kopiert.
, wenn wir Bilder in der Liste haben, können wir, dass in neue Powerpoint-Datei Schaffung neuer PPT-Dokument
Bitte lassen Sie mich hinzufügen, wissen, wie man Bilderliste
public List<Image> Chartimages;
public List<Metafile> ChartimagesMetafile;
public List<BitmapSource> ChartimagesBitmapSource;
public void InsertChartIntoChartlist()
{
try
{
// Create an instance of PowerPoint.
powerpointApplication = new pptNS.Application();
// Create an instance Excel.
excelApplication = new xlNS.Application();
// Open the Excel workbook containing the worksheet with the chart
// data.
excelWorkBook = excelApplication.Workbooks.Open(paramWorkbookPath,
paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing);
// Get the worksheet that contains the chart.
targetSheet = (xlNS.Worksheet)(excelWorkBook.Worksheets[2]);
// Get the ChartObjects collection for the sheet.
chartObjects = (xlNS.ChartObjects)(targetSheet.ChartObjects(paramMissing));
foreach (xlNS.ChartObject item in chartObjects)
{
// // Get the chart to copy.
existingChartObject = (xlNS.ChartObject)(item);
// Copy the chart from the Excel worksheet to the clipboard.
existingChartObject.CopyPicture(xlNS.XlPictureAppearance.xlPrinter, xlNS.XlCopyPictureFormat.xlPicture);
if (Clipboard.ContainsData(System.Windows.DataFormats.EnhancedMetafile))
{
Metafile metafile = Clipboard.GetData(System.Windows.DataFormats.EnhancedMetafile) as Metafile;
// metafile.Save(fileName);
ChartimagesMetafile.Add(metafile);
}
else if (Clipboard.ContainsData(System.Windows.DataFormats.Bitmap))
{
BitmapSource bitmapSource = Clipboard.GetData(System.Windows.DataFormats.Bitmap) as BitmapSource;
ChartimagesBitmapSource.Add(bitmapSource);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
Dank
to Clipboard hinzufügen Schließlich, wer auch immer das abgelehnt hat: Wir lernten alle eines Tages, wie man etwas macht, da ein Anfänger definitiv programmierbezogen ist, unabhängig davon, wie neu jemand sein könnte.
Ryan löste ich es in besseren Weg –