Telerik Forums
Telerik Document Processing Forum
1 answer
5.3K+ views
Hello,

Our MVC/Kendo project utilized Telerik.Documents.SpreadsheetStreaming library to export data to Excel file. Now we'd like to do reverse process - IMPORT process which read data from physical location (through file system or from database) to C# object. I didn't find related Interface or method in Telerik.Documents.SpreadsheetStreaming. Could someone point out which library is the better way to do so. Thanks  in advance!
Martin
Telerik team
 answered on 29 Jun 2020
2 answers
564 views

Hi

I'm trying to create report as a PDF file and the report might have several PDF documents as appendixes. 

01.
02.RadFixedDocument reportPdf = CreateReportPdf();
03.foreach(RadFixedDocument appendixPdf = appendixes)
04.{
05.  // here I would like to scale appendixPdf to 80% of reportPdf.
06.  // Then I would like to add some header/footer telling which appendix file that has been added
07.  reportPdf.merge(appendixPdf);
08.}
09.return reportPdf;

 

I hope the above example gives an idea on what I'm trying to do. Hope somebody can give some inspiration on how to accomplish it.

 

Yours
/peter

Peter
Top achievements
Rank 1
 answered on 12 Jun 2020
6 answers
1.5K+ views

Hi! I'm generating an Excel document containing various fonts of "HelveticaNeue". Please see attached images for samples.

When exporting to pdf using PdfFormatProvider, the font styles are changed, e.g. bold style disappears. However, when exporting using Excel interops it works.

Code using interops:

public static void ExcelToPdf( string xlFilePath, string pdfOutputPath )
{
    try
    {
        Excel.Application app = new Excel.Application();
        app.Visible = false;
        app.DisplayAlerts = false;
        Excel.Workbook wkb = app.Workbooks.Open( xlFilePath, ReadOnly: true );
        wkb.ExportAsFixedFormat( Excel.XlFixedFormatType.xlTypePDF, pdfOutputPath );
 
        wkb.Close();
        app.Quit();
    }
    catch ( Exception ex )
    {
        Console.WriteLine( ex.StackTrace );
        throw ex;
    }
}

 

Code using Telerik PdfFormatProvider:

public override void Generate( DimensionTableInput input )
{
    CreateWorkbook();
    CreateWorkbookStyles();
    CreateWorksheets( input );
 
    XlsxFormatProvider xlsxFormatProvider = new XlsxFormatProvider();
 
    PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();
    // this will result in 1 page per sheet
    pdfFormatProvider.ExportSettings = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.Export.PdfExportSettings( ExportWhat.EntireWorkbook, true );
 
    string xlsxFileName = $"{input.DocumentTitle}.xlsx";
    string xlsxFullPath = $"{ Path.Combine( input.OutputPath, xlsxFileName )}";
    ExportToFile( xlsxFormatProvider, xlsxFullPath );
 
    string pdfFileName = $"{input.DocumentTitle}.pdf";
    string pdfFullPath = $"{ Path.Combine( input.OutputPath, pdfFileName )}";
    ExportToFile( pdfFormatProvider, pdfFullPath );
    //Helpers.ExcelHelper.ExcelToPdf( xlsxFullPath, pdfFullPath );
}
 
private void ExportToFile( IWorkbookFormatProvider formatProvider, string fileName )
{
    using ( Stream fs = File.OpenWrite( fileName ) )
    {
        formatProvider.Export( _workbook, fs );
    }
}

 

I can share the original Excel and Pdf files if needed.

Thanks in advance,

John

Chris
Top achievements
Rank 1
 answered on 11 Jun 2020
3 answers
113 views

I need to read the data from an excel file (not formatted) and in order to do this I need to find a cell that contains a specific text.

I am trying to do this

FindOptions options = new FindOptions()
{
    FindWhat = "Record",
    MatchEntireCellContents = true
};

but it fails with:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Windows.Documents.Spreadsheet.Utilities.FindAndReplaceHelper.MoreThan(WorksheetCellIndex left, WorksheetCellIndex right, FindBy searchBy)
   at Telerik.Windows.Documents.Spreadsheet.Utilities.FindAndReplaceHelper.<>c__DisplayClass3_0.<OrderResults>b__0(FindResult result)
   at System.Linq.Enumerable.TakeWhileIterator[TSource](IEnumerable`1 source, Func`2 predicate)+MoveNext()
   at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
   at Telerik.Windows.Documents.Spreadsheet.Utilities.FindAndReplaceHelper.OrderResults(FindOptions findOptions, IEnumerable`1 findResults)
   at Telerik.Windows.Documents.Spreadsheet.Model.Workbook.Find(FindOptions findOptions)

While looking in the code I have discovered that is because the StartCell is null. Where does it say that the StartCell is mandatory? Also why is the StartCell mandatory?

Dimitar
Telerik team
 answered on 27 May 2020
2 answers
1.1K+ views

Hi,

 

Is there a way to check if a pdf file is corrupted using pdfprocessing?

 

i'm working on a upload pdf file tool and it will be nice to check if the pdf is or not corrupted before upload. I've already check if the file header is pdf but some corrupted files gone thought.

 

Thanks!!

ANTONIO
Top achievements
Rank 1
 answered on 26 May 2020
5 answers
1.4K+ views
It seems like the api does not have the ability to read and insert values into a pdf fillable form. Will this feature be implemented in the near future? If so, any timeline? Thanks.
Dimitar
Telerik team
 answered on 21 May 2020
1 answer
290 views
It appears that the PDF export in the dotnet core/standard version is broken. No font data is retained. Instead all fonts are changed to the default font, font weight, and style. The only font property that is retained through conversion is the size. I noticed that there are others complaining about this in the Framework version but I have not seen any progress in fixing the problem or work around suggested. Is there a way to export to PDF a flex document with some control over the font weight and style?
Dimitar
Telerik team
 answered on 20 May 2020
1 answer
87 views

Hi,

I'm implementing custom cell editor using spreadprocessing to create a template for user to export and edit.  After they are done, they import back using the Telerik built-in import function.  I have no problem when creating the validation in the cells as I followed your example here:

https://demos.telerik.com/aspnet-ajax/spreadsheet/examples/custom-editors/defaultcs.aspx

When I tried to open the export file, I would get an error : "We found a problem with some content in "abcd.xlsx".  Do you want us to try to recover as much as we can? ..."  After I clicked 'Yes', my custom cell editors disappeared.

The same error occurs when I export from your demo.  However, if I create a spreadsheet with validation from scratch, everything works perfectly.

Please help!

Thank you,

Helen

Peter Milchev
Telerik team
 answered on 14 May 2020
2 answers
549 views

I'm using Telerik in an interop environment with C++ and trying to replace our old ZIP library.  With the code below it appears to ZIP all files correctly except the last file always has some error with it like it isn't being written out properly.  I've changed the number and type of files and the specific file type doesn't matter, the last one in the archive is always corrupted when i test the archive.

 

    System::String^ sSource = gcnew System::String(m_sPath1);
        System::String^ sDest = gcnew System::String(sZipDest);
        
        System::IO::File^ file = nullptr;
        System::IO::Stream^ stream = file->Open(sDest, System::IO::FileMode::Create);
        Telerik::Windows::Zip::ZipArchive^ zarchive = gcnew Telerik::Windows::Zip::ZipArchive(stream, Telerik::Windows::Zip::ZipArchiveMode::Create,false,System::Text::Encoding::UTF8);
         
        Telerik::Windows::Zip::DeflateSettings^ compressionSettings = gcnew Telerik::Windows::Zip::DeflateSettings();
        compressionSettings->CompressionLevel = Telerik::Windows::Zip::CompressionLevel::Best;
        compressionSettings->HeaderType = Telerik::Windows::Zip::CompressedStreamHeader::ZLib;
 
        pList3->ResetContent();
        rc = 0;
        nCount = pList1->GetCount();
        for (n = 0; n<nCount; n++) {
            pList1->GetText(n, sFileName);
            sFullyQualifiedFileNameFrom = fs.AppendWildcard(m_sPath1, sFileName);
            int nSel = pList3->AddString(sFileName);
            pList3->SetCurSel(nSel);
            pList3->UpdateWindow();
            System::String^ sFull = gcnew System::String(sFullyQualifiedFileNameFrom.GetBuffer());
            System::String^ sName = gcnew System::String(sFileName.GetBuffer());
            Telerik::Windows::Zip::Extensions::ZipFile::CreateEntryFromFile(zarchive, sFull, sName, compressionSettings);
            int nFilesPercent = 100 * (n + 1) / nCount;
            m_prStatus.SetPos(nFilesPercent);
        }
        Sleep(5000);
        stream->Flush();
        stream->Close();

 

Is there something else that should be done to finish the compression/writing of the last file when in the loop using CreateEntryFromFile?  

Martin
Telerik team
 answered on 13 May 2020
1 answer
458 views

Hi

I'm using RadFixedDocumentEditor to insert several line of text (editor.InsertRun and editor.InsertLine).

I use InsertLine and like HorizontalAlignment = left.

But how can I insert justified line of text ? Is it possible ??

Tanks

Tanya
Telerik team
 answered on 11 May 2020
Narrow your results
Selected tags
Tags
+? more
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?