1-) C# RMOS - doc to txt docx word den stringe texte çevirme ve xtrareport da gösterme devexpress
dll ekle
C:\Program Files\DevExpress 22.2\Components\Bin\Framework\DevExpress.XtraReports.v22.2.dll
using DevExpress.XtraReports.UI; using DevExpress.XtraRichEdit; using System; using System.Windows.Forms; namespace docxtotext { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { XtraReport1 xtraReport1 = new XtraReport1(); string filePath = @"C:\Users\RAMBO4\Desktop\headersiz.doc"; using (RichEditDocumentServer reds = new RichEditDocumentServer()) { reds.LoadDocument(filePath, DocumentFormat.Doc); xtraReport1.xrRichText1.Rtf = reds.RtfText; //reds.SaveDocument("secondParagraph.docx", DocumentFormat.OpenXml);
} xtraReport1.ShowPreview(); } } }
|
2- NET CORE APİ 7 İÇİN
[HttpPost] [Route("downloadFile4")] public IActionResult downloadFile4(int id) { using var context = new Context(); var dosyam = context.Files.Where(x => x.id == id).FirstOrDefault(); if (dosyam == null) return NotFound();
string ftpUrl = "ftp://ipport/" + dosyam.path; string ftpUsername = "username"; string ftpPassword = "sifre";
try { var fileContents = DownloadFileFromFtp(ftpUrl, ftpUsername, ftpPassword);
if (fileContents == null) { return NotFound("Dosya bulunamadı veya erişim izniniz yok."); }
Report1 report1 = new Report1(); using (RichEditDocumentServer reds = new RichEditDocumentServer()) { reds.LoadDocument(fileContents, DocumentFormat.Doc); report1.txtAciklama.Rtf = reds.RtfText; }
using (MemoryStream stream = new MemoryStream()) { report1.ExportToDocx(stream); var result = stream.ToArray();
// İstemciye dosyayı indirme işlemi return File(result, "application/octet-stream", dosyam.orjiAd ); }
//return File(fileContents, "application/octet-stream", dosyam.orjiAd); } catch (WebException ex) { if (ex.Response is FtpWebResponse response && response.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable) { return NotFound("Dosya bulunamadı veya erişim izniniz yok."); } else { return BadRequest("Dosya indirilirken bir hata oluştu: " + ex.Message); } } catch (Exception ex) { return BadRequest("Beklenmeyen bir hata oluştu: " + ex.Message); } }
[ApiExplorerSettings(IgnoreApi = true)] [NonAction] [Route("downloadFile2")] [HttpPost] public Stream downloadFile2(Files file) { string ftpUrl = "ftp://ipport/" + file.path; //
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpUrl));
request.Credentials = new NetworkCredential("username", "sifre"); request.Method = WebRequestMethods.Ftp.DownloadFile; Stream reader = request.GetResponse().GetResponseStream(); return reader; }
|