Show / Hide Table of Contents

    DataStoreDataExtensions.ExportString(this IDataStoreBase dataStore, int startRow, int endRow, bool colheading = true) Method

    .NET Standard 2.x

    Exports the rows (from the specified starting position to the ending position) from the primary buffer of the DataStore to a string. The column name is exported by default.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

      public static int ImportString(this IDataStoreBase dataStore, int startRow, int endRow, bool colheading = true);
    

    Parameters

    startRow System.Int32

    The zero-based index number for the starting row.

    If it is negative, it indicates the first row; if it is larger than RowCount, no rows will be exported.

    endRow System.Int32

    The zero-based index number for the ending row.

    If it is negative, it indicates the rest of rows.

    colheading System.Boolean

    True (default): The column name is exported.

    False: The column name is not exported.

    Returns

    System.String

    Returns the string if it succeeds.

    Remarks

    Values are separated by tabs. A newline character ("\r\n" for non-Unix platforms, and "\n" for Unix platforms) is placed at the end of each line.

    Examples

    The following code example demonstrates how to use the ExportString method to export the first and the second department records (with or without column heading) from the primary buffer to a string.

    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.DataStoreDataExtensionsExamples
    {
        public class ExportStringExample
        {
            private readonly SchoolContext _context;
    
            public ExportStringExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example2()
            {
                // Instantiates a DataStore object with datawindow: d_department.
                var datastore = new DataStore("d_department", _context);
    
                // Generates data in the primary/delete/filter buffers for this example.
                datastore.Retrieve();
                datastore.DeleteRow(0);
                datastore.SetFilter("departmentid < 5");
                datastore.Filter();
    
                // Exports the first and second rows to a string with column headings.
                string text = datastore.ExportString(0, 1);
    
                Console.WriteLine("datastore.ExportString(0, 1):");
                Console.WriteLine(text);
    
                // Exports the first and second rows to a string without column headings.
                text = datastore.ExportString(0, 1, false);
    
                Console.WriteLine("datastore.ExportString(0, 1, false):");
                Console.WriteLine(text);
    
                /*This code produces the following output:
    
               datastore.ExportString(0, 1):
                "Departmentid"  "Name"  "Budget"        "Startdate"     "Administrator"
                2       "English"       120000.0000     9/1/2007 12:00:00 AM    6
                4       "Economics"     200000.0000     9/1/2007 12:00:00 AM    4
    
                datastore.ExportString(0, 1, false):
                2       "English"       120000.0000     9/1/2007 12:00:00 AM    6
                4       "Economics"     200000.0000     9/1/2007 12:00:00 AM    4 
               */
            }
        }
    }
    

    Example Refer To

    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon