/*------------------------------------------------------------------------------*
 * File Name: CSVFile.h															*
 * Creation: 	Hong	2006-12-21												*
 * Purpose: OriginC Header C file												*
 * Copyright (c) OriginLab Corp. 2004											*
 *																				*
 * Modification Log:															*
 * Sim 03-19-2007 PARTIAL_IMPORT												*
 * Hong 03/30/07 v8.0593 ADD_HEADER_LINE_OPTION									*
 *------------------------------------------------------------------------------*/
 
#ifndef	CSV_FILE_H
#define	CSV_FILE_H

/// Hong 09/03/07 v8.0694 ALLOW_USER_SPECIFY_EXSCAPE_CHARACTER
enum
{
	ESCAPE_CHARACTER_FMT_AUTO = 0,
	ESCAPE_CHARACTER_FMT_DOS,
	ESCAPE_CHARACTER_FMT_OTHERS, 
};
/// end ALLOW_USER_SPECIFY_EXSCAPE_CHARACTER

class CSVFile : public stdioFile
{
public:
	CSVFile()
	{ 
	 	m_nColNum = 0;
		m_nRowNum = 0;
	}

	CSVFile(LPCSTR lpcszFileName)
	{ 
	 	m_nColNum = 0;
		m_nRowNum = 0;
		bIsOpenFile = Open(lpcszFileName, file::modeRead | file::typeBinary);
	}
	
	~CSVFile()
	{
		//if ( bIsOpenFile )
		Close();
	}
public:	
	///---Sim 03-19-2007 PARTIAL_IMPORT
	//int Import(LPCSTR lpcszFileName, Worksheet& wks, TreeNode& trFileInfo, int nC1 = 0, int nR1 = 0);
	/// Hong 03/30/07 v8.0593 ADD_HEADER_LINE_OPTION
	//int Import(LPCSTR lpcszFileName, Worksheet& wks, TreeNode& trFileInfo, int nC1 = 0, int nR1 = 0, \
			//int nColFrom = 0, int nColTo = -1, int nRowFrom = 0, int nRowTo = -1);
	/// Hong 09/03/07 v8.0694 ALLOW_USER_SPECIFY_EXSCAPE_CHARACTER
	//int Import(LPCSTR lpcszFileName, Worksheet& wks, TreeNode& trFileInfo, int nC1 = 0, int nR1 = 0, \
	//		int nColFrom = 0, int nColTo = -1, int nRowFrom = 0, int nRowTo = -1, TreeNode& trOption = NULL);
	int Import(LPCSTR lpcszFileName, Worksheet& wks, TreeNode& trFileInfo, int nC1 = 0, int nR1 = 0, \
			int nColFrom = 0, int nColTo = -1, int nRowFrom = 0, int nRowTo = -1, TreeNode& trOption = NULL, int nEscapeCharacterFmt = ESCAPE_CHARACTER_FMT_AUTO);
	/// end ALLOW_USER_SPECIFY_EXSCAPE_CHARACTER
	/// end ADD_HEADER_LINE_OPTION
	///---END PARTIAL_IMPORT
	
	DataRange GetDataRange() { return m_orng; }
private:
	
protected:
	int m_nColNum;
	int m_nRowNum;
	bool bIsOpenFile;
	
	DataRange m_orng;
};

#endif //CSV_FILE_H