Options

Exporting blob field possible?

RoelofRoelof Member Posts: 377
Is there a way to export a blob field thru a dataport?
I'm getting an error when trying to define a Blob field as export field in a dataport.
Thanks.
Roelof de Jonghttp://www.wye.com

Comments

  • Options
    SavatageSavatage Member Posts: 7,142
    I use the EXPORT function to export BLOB fields.

    What's stored in your blob field...Pic or text?

    http://msdn.microsoft.com/en-us/library/dd338648.aspx
  • Options
    RoelofRoelof Member Posts: 377
    I'm trying to export the Stylesheet table.
    The blob field probably contains the image of the word or excel template.
    Roelof de Jonghttp://www.wye.com
  • Options
    vaprogvaprog Member Posts: 1,125
    Roelof wrote:
    I'm trying to export the Stylesheet table.
    The blob field probably contains the image of the word or excel template.

    The Blob contains the Stylesheet (.xslt), which transforms an XML-representation of the Form's controls into an XML-representation of the office document. You can export it from the GUI.

    In case you're looking for the logo image, it's in the stylesheet in a base64 encoded string.
  • Options
    RoelofRoelof Member Posts: 377
    I found a dataport sample online.
    It basically exports the Blob field separately into a file. So, for 5 records you have 5 files.

    Data looks like:

    StyleSheet - OnPreDataItem()
    //Setup file path for BLOB files
    FilePath := CurrDataport.FILENAME;
    IF STRPOS(FilePath,'\') = 0 THEN
    FilePath := ''
    ELSE
    REPEAT
    IF COPYSTR(FilePath,STRLEN(FilePath),1) <> '\' THEN
    FilePath := COPYSTR(FilePath,1,STRLEN(FilePath)-1);
    UNTIL COPYSTR(FilePath,STRLEN(FilePath),1) = '\';

    StyleSheet - OnBeforeExportRecord()

    StyleSheet - OnAfterExportRecord()
    //Export blobs as bmp files
    CALCFIELDS("Style Sheet");
    IF "Style Sheet".HASVALUE THEN BEGIN
    StyleSheetFileName := FilePath + '_' + FORMAT("Style Sheet ID");
    "Style Sheet".EXPORT(StyleSheetFileName,FALSE);
    END;

    StyleSheet - OnBeforeImportRecord()

    StyleSheet - OnAfterImportRecord()
    //Import blobs from bmp files
    IF StyleSheetRec2.GET("Style Sheet ID") THEN BEGIN
    CALCFIELDS("Style Sheet");
    IF "Style Sheet".HASVALUE THEN
    CLEAR("Style Sheet");
    END;

    StyleSheetFileName := FilePath + '_' + FORMAT("Style Sheet ID");
    IF StyleSheetFile.OPEN(StyleSheetFileName) THEN BEGIN
    StyleSheetFile.CLOSE;
    "Style Sheet".IMPORT(StyleSheetFileName,FALSE);
    END ELSE
    CLEAR("Style Sheet");

    StyleSheet - OnPostDataItem()
    Roelof de Jonghttp://www.wye.com
Sign In or Register to comment.