<< Return to Main Index

< Return to Class Index

CGXGridCore::CopyCellsToArchive

virtual BOOL CopyCellsToArchive(CArchive& ar, const CGXRangeList& selList, BOOL bLoadBaseStyles = FALSE);

BOOL CopyCellsToArchive(CArchive& ar, const CGXRange& range, BOOL bLoadBaseStyles = FALSE);

ar

Reference to the CArchive object.

selList

A reference to the range list which contains all the cell ranges which shall be written to the file.

range

Specifies a single range of cells which shall be written to the file.

bLoadBaseStyles

Specifies whether the composed base-style shall be written to the archive or only the individual style attributes for the cells. You should pass TRUE if you want all cell objects to be fully composed.

Remarks

Serializes the cell (style) objects of the specified range of cells to a CArchive.

The second prototype of this method is simply a wrapper for calling CopyTextToFile with a single range instead of a range list.

This method will mainly be called for copying cells in internal format to the clipboard, but you may also use it for writing a range of cells to a file.

Control-Factory Specific ->

This method has been implemented using the abstraction mechanism as discussed in the chapter "Reducing the size of your application" in the user's guide. A call to the ImplementStyleDataExchange method from within the control factory class' InitializeGridComponents method will make the concrete implementation of this method available to your application.

If no concrete implementation is available this method returns FALSE. A warning will be displayed in the debug window.

END Control-Factory Specific

Example

This sample demonstrates how you can save the whole grid in an internal format to an archive:

void CGridSampleView::OnSaveToArchive( )
{
   // pop-up file-open dlg to ask for location
   CFileDialog dlgFile(
      FALSE,
      _T(".grd"),
      NULL,
      OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
      _T("Grid Files (*.grd)|*.grd|All Files (*.*)|*.*||"));

   if (dlgFile.DoModal( ) == IDCANCEL)
      return;

   CFile gridFile;

   if (!gridFile.Open(dlgFile.GetFileName( ),
      CFile::modeCreate | CFile::modeWrite))
   {
      TCHAR sz[255];
      wsprintf(sz, "File %s could not be opened!", dlgFile.GetFileName( ));
      AfxMessageBox(sz);
      return;
   }

   CArchive ar(&gridFile, CArchive::store);

   CopyCellsToArchive(ar,
      CGXRange(0, 1, GetRowCount( ), GetColCount( )),
      TRUE);

   ar.Close( );
   gridFile.Close( );
}

See Also

CGXGridCore::Copy CGXGridCore::CopyRange

CGXGridCore

Class Overview | Class Members