Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Create CSV FileDemonstrates how to create a new CSV file with some simple content.
Use ChilkatAx-win32.pkg Procedure Test Handle hoCsv Boolean iSuccess String sCsvDoc String sTemp1 // This sample code creates a new CSV file (sample.csv) // that contains this content: // // year,color,country,food // 2001,red,France,cheese // 2005,blue,"United States",hamburger Get Create (RefClass(cComChilkatCsv)) To hoCsv If (Not(IsComObjectCreated(hoCsv))) Begin Send CreateComObject of hoCsv End // Indicate that the 1st row // should be treated as column names: Set ComHasColumnNames Of hoCsv To True Get ComSetColumnName Of hoCsv 0 "year" To iSuccess Get ComSetColumnName Of hoCsv 1 "color" To iSuccess Get ComSetColumnName Of hoCsv 2 "country" To iSuccess Get ComSetColumnName Of hoCsv 3 "food" To iSuccess Get ComSetCell Of hoCsv 0 0 "2001" To iSuccess Get ComSetCell Of hoCsv 0 1 "red" To iSuccess Get ComSetCell Of hoCsv 0 2 "France" To iSuccess Get ComSetCell Of hoCsv 0 3 "cheese" To iSuccess Get ComSetCell Of hoCsv 1 0 "2005" To iSuccess Get ComSetCell Of hoCsv 1 1 "blue" To iSuccess Get ComSetCell Of hoCsv 1 2 "United States" To iSuccess Get ComSetCell Of hoCsv 1 3 "hamburger" To iSuccess // Write the CSV to a string and display: Get ComSaveToString Of hoCsv To sCsvDoc Showln sCsvDoc // Save the CSV to a file: Get ComSaveFile Of hoCsv "out.csv" To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoCsv To sTemp1 Showln sTemp1 End End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.