update 20240925
This commit is contained in:
@@ -56,7 +56,7 @@ namespace DOCGEN.Generator
|
||||
{
|
||||
case "DOCX": case "DOCM": case "DOC": case "DOT":
|
||||
case "WORD": case "DOTM":
|
||||
SynFWord sfword = new SynFWord();
|
||||
SyncFWord sfword = new SyncFWord();
|
||||
generate_docdata(dokumentid, ref docdata);
|
||||
clsdok dok = new clsdok("", "", "");
|
||||
dok.dokument= sfword.Generate_Word(dt.Rows[0][0].ToString(), docdata);
|
||||
@@ -65,7 +65,12 @@ namespace DOCGEN.Generator
|
||||
//if (dok.extension.ToUpper()=="DOTM") { dok.extension = "docm"; }
|
||||
return dok;
|
||||
case "XLSM": case "XLSX": case "XLST": case "XLS": case "XLT":
|
||||
SyncFExcel sfexcel = new SyncFExcel();
|
||||
generate_docdata(dokumentid, ref docdata);
|
||||
clsdok dokexcel = new clsdok("", "", "");
|
||||
dokexcel.dokument = sfexcel.Generate_Excel(dt.Rows[0][0].ToString(), docdata);
|
||||
dokexcel.doktype = "X";
|
||||
dokexcel.extension = dt2.Rows[0][1].ToString();
|
||||
return dokexcel;
|
||||
//break;
|
||||
case "PDF": case "ACROBAT": case "FORMULAR": case "DOKUMENT":
|
||||
|
||||
100
DOCGEN/Klassen/SyncFExcel.cs
Normal file
100
DOCGEN/Klassen/SyncFExcel.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Model;
|
||||
using Syncfusion.DocIO.DLS;
|
||||
using Syncfusion.XlsIO;
|
||||
|
||||
namespace DOCGEN.Klassen
|
||||
{
|
||||
public class SyncFExcel
|
||||
{
|
||||
public bool create_nativ(string property, string value, string base64, string originalfile, string destfile)
|
||||
{
|
||||
FileStream ms = new FileStream(originalfile, FileMode.Open, FileAccess.Read);
|
||||
FileStream os = new FileStream(destfile, FileMode.Create);
|
||||
ExcelEngine ex = new ExcelEngine();
|
||||
IApplication application = ex.Excel;
|
||||
IWorkbook workbook = application.Workbooks.Open(ms);
|
||||
|
||||
try
|
||||
{
|
||||
workbook.CustomDocumentProperties[property].Text = value;
|
||||
}
|
||||
catch
|
||||
{
|
||||
workbook.CustomDocumentProperties.Remove(property);
|
||||
workbook.CustomDocumentProperties[property].Text = value;
|
||||
|
||||
}
|
||||
workbook.Replace("{" + property + "}", value);
|
||||
//workbook.Names[workbook.CustomDocumentProperties[property].Name].RefersToRange.Text= workbook.CustomDocumentProperties[property].Text;
|
||||
workbook.SaveAs(os);
|
||||
workbook.Close();
|
||||
workbook = null;
|
||||
application = null;
|
||||
ms.Close();
|
||||
ms.Dispose();
|
||||
os.Close();
|
||||
os.Dispose();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public string Generate_Excel(string base64, clsDocData docdata)
|
||||
{
|
||||
ExcelEngine ex = new ExcelEngine();
|
||||
IApplication app = ex.Excel;
|
||||
MemoryStream ms = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(base64));
|
||||
IWorkbook workBook = app.Workbooks.Open(ms, ExcelOpenType.Automatic);
|
||||
|
||||
string formattype = "";
|
||||
|
||||
foreach (clsDocValue dv in docdata.DocValues)
|
||||
{
|
||||
foreach (IWorksheet worksheet in workBook.Worksheets)
|
||||
{
|
||||
if (dv.FieldName== "TGEDKNameInhaber")
|
||||
{
|
||||
var a = 0;
|
||||
}
|
||||
try
|
||||
{
|
||||
worksheet.Range[dv.FieldName].Text = dv.Value.ToString();
|
||||
}
|
||||
catch { }
|
||||
|
||||
//foreach (IName name in worksheet.Names)
|
||||
//{
|
||||
|
||||
// name.Value = dv.Value.ToString();
|
||||
// Debug.Print(name.Value);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
MemoryStream destms = new MemoryStream();
|
||||
workBook.SaveAs(destms);
|
||||
workBook.Close();
|
||||
workBook = null;
|
||||
ex.Dispose();
|
||||
|
||||
byte[] imageArray = destms.ToArray();
|
||||
|
||||
if (docdata.Result_as_PDF == "True")
|
||||
{
|
||||
DocGet getdoc = new DocGet("");
|
||||
string destdoc = "";
|
||||
destdoc = getdoc.Convert_Word_To_PDF(Convert.ToBase64String(imageArray));
|
||||
return destdoc;
|
||||
}
|
||||
|
||||
return Convert.ToBase64String(imageArray);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace DOCGEN.Klassen
|
||||
}
|
||||
try
|
||||
{
|
||||
ITextSelection[] textSelections = pptxDoc.FindAll(property, false, false);
|
||||
ITextSelection[] textSelections = pptxDoc.FindAll("{"+property+"}", false, false);
|
||||
foreach (ITextSelection textSelection in textSelections)
|
||||
{
|
||||
|
||||
@@ -40,17 +40,6 @@ namespace DOCGEN.Klassen
|
||||
|
||||
textPart.Text = value;
|
||||
}
|
||||
|
||||
// ITextSelection[] textSelection = pptxDoc.FindAll(property, false, false);
|
||||
// foreach (ITextSelection textSelection in textSelections)
|
||||
// {
|
||||
// //Get the found text as a single text part.
|
||||
// ITextPart textPart = textSelection.GetAsOneTextPart();
|
||||
// //Replace the text.
|
||||
// textPart.Text = value;
|
||||
// }
|
||||
//// ITextPart textPart = textSelection.GetAsOneTextPart();
|
||||
// // textPart.Text = value;
|
||||
}
|
||||
catch { }
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ using System.Security.Permissions;
|
||||
|
||||
namespace DOCGEN.Klassen
|
||||
{
|
||||
public class SynFWord
|
||||
public class SyncFWord
|
||||
{
|
||||
public bool create_nativ(string property, string value, string base64, string originalfile, string destfile)
|
||||
{
|
||||
@@ -51,7 +51,7 @@ namespace DOCGEN.Klassen
|
||||
|
||||
}
|
||||
|
||||
TextSelection[] textSelections = document.FindAll("{Klassifizierung}", false, true);
|
||||
TextSelection[] textSelections = document.FindAll("{" + property + "}", false, true);
|
||||
foreach (TextSelection textSelection in textSelections)
|
||||
{
|
||||
//Gets the found text as single text range and sets highlight color
|
||||
@@ -71,7 +71,7 @@ namespace DOCGEN.Klassen
|
||||
|
||||
string formattype = "";
|
||||
MemoryStream ms = new MemoryStream(Helper.EncodeExtensions.DecodeBase642ByteArray(base64));
|
||||
WordDocument document = new WordDocument(ms, FormatType.Doc);
|
||||
WordDocument document = new WordDocument(ms, FormatType.Automatic);
|
||||
formattype = document.ActualFormatType.ToString();
|
||||
var formattype_original = document.ActualFormatType;
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Syncfusion.XlsIO;
|
||||
|
||||
namespace DOCGEN.Klassen
|
||||
{
|
||||
public class SynFExcel
|
||||
{
|
||||
public bool create_nativ(string property, string value, string base64, string originalfile, string destfile)
|
||||
{
|
||||
FileStream ms = new FileStream(originalfile, FileMode.Open, FileAccess.Read);
|
||||
FileStream os = new FileStream(destfile, FileMode.Create);
|
||||
ExcelEngine ex = new ExcelEngine();
|
||||
IApplication application = ex.Excel;
|
||||
IWorkbook workbook = application.Workbooks.Open(ms);
|
||||
|
||||
try
|
||||
{
|
||||
workbook.CustomDocumentProperties[property].Text = value;
|
||||
}
|
||||
catch
|
||||
{
|
||||
workbook.CustomDocumentProperties.Remove(property);
|
||||
workbook.CustomDocumentProperties[property].Text = value;
|
||||
|
||||
}
|
||||
workbook.Replace("{Klassifizierung}", value);
|
||||
//workbook.Names[workbook.CustomDocumentProperties[property].Name].RefersToRange.Text= workbook.CustomDocumentProperties[property].Text;
|
||||
workbook.SaveAs(os);
|
||||
workbook.Close();
|
||||
workbook = null;
|
||||
application = null;
|
||||
ms.Close();
|
||||
ms.Dispose();
|
||||
os.Close();
|
||||
os.Dispose();
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user