/*------------------------------------------------------------------------------* * File Name: RemoveQuotesFromWorksheetCells.c * * Creation: Forum post by Mike Buess: * * http://www.originlab.com/forum/topic.asp?TOPIC_ID=3664 * * Purpose: Programming Example * * * * * Modification Log: * *------------------------------------------------------------------------------*/ #include ///////////////////////////////////////////////////////////////////////////////// // This example shows how to remove quotes from the contents of all cells in // a worksheet. This code segment was posted by Mike Buess in the following // forum thread: http://www.originlab.com/forum/topic.asp?TOPIC_ID=3664 // void remove_quotes_from_worksheet_cells() { // Declare worksheet using active layer Worksheet wks = Project.ActiveLayer(); if( wks ) { Dataset ds; StringArray sa; string str; // loop over each column in wks and remove quotes foreach( Column col in wks.Columns ) { // Attach column to the datset ds.Attach(col); // Get all contents of column into string array ds.GetStringArray(sa); // Copy to string, adding | as delimiter token for each cell str.SetTokens(sa, '|'); // Remove all quotes str.Remove('"'); // Copy string back to string array str.GetTokens(sa, '|'); // Copy string array back to dataset, thus updating column ds.PutStringArray(sa); } } else out_str("Active layer is not a worksheet!"); }