⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wksheet.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 5 页
字号:
/*------------------------------------------------------------------------------*
 * File Name: Wksheet.h															*
 * Creation: CPY 4/2/2001														*
 * Purpose: Origin C header	for Worksheet class and other related functions		*
 * Copyright (c) OriginLab Corp.2001											*
 * All Rights Reserved															*
 *------------------------------------------------------------------------------*/

#ifndef _WKSHEET_H
#define _WKSHEET_H

#include <common.h> // must always include this, has printf etc

#ifndef _STRING_H //string.h is big, so we should not even load if not needed 
#include <string.h> // most likely you will also need strings
#endif //!_STRING_H

#include <OC_const.h> // consts used in Origin internal functions
#include <Collection.h> //Contains declaration of the template class Collection

#ifndef _GRAPH_H // graph.h is big, avoid loading if possible
#include <graph.h> // graph, plot and graphic objects
#endif //!_GRAPH_H

/** >Internal Origin Objects
		The Datasheet class provides methods and properties common to Origin worksheet
		and matrix layers. The Datasheet class is derived from the Layer and OriginObject
		classes from which it inherits methods and properties.
*/
class Datasheet : public Layer
{
public:

/**
	Default constructor.
*/
	Datasheet();
	/**#
	*/
	Datasheet(Layer & layer);
/**
		Get the number of columns in a Datasheet including MatixLayers and Worksheets.
	Example: 
		Worksheet wks("Data1");
		int nCols = wks.GetNumCols();
	Return: 
		Returns the number of columns in the Datasheet including MatixLayers and Worksheets.
	SeeAlso:
		Datasheet::GetNumRows, Datasheet::SetNumRows
*/
	UINT	GetNumCols(); // Get the number of columns in the Datasheet.
	
/**
	Remarks: 
		Retrieves the name of the worksheet. This function is useful only for Excel
		workbooks where one workbook can have multiple sheets, each with its own name.
	Return: 
		The TRUE for succes, FALSE if failed.
	Example: 
		Page		pg("Book1");
		Layer		lay= pg.Layers();		// gets the active worksheet from Excel
		Worksheet	wks;
		wks = (Worksheet)lay;
		if (wks)
		{
			string	strName;
			wks.GetName(strName);
			out_str(strName);
		}
*/
	BOOL	GetName(string &str);

/**
		Get the number of rows in a Datasheet including MatixLayers and Worksheets.
	Example: 
		Worksheet wks("Data1");
		int nRows = wks.GetNumRows();
	Return: 
		Returns the number of rows in the Datasheet including MatixLayers and Worksheets.
	SeeAlso: 
		Datasheet::GetNumCols, Datasheet::SetNumRows
*/	
	UINT	GetNumRows(); // Get the number of rows in the Datasheet.
	
/**
		Create a new worksheet or matrix using the supplied template 
		and attach it to the object.
	Parameters: 
		lpcszTemplate = the template file name, "" or NULL to use a default template. 
						"0" to create without template
		nOption = enum {
						CREATE_TEMP = 0,	// it will be destroyed when destroying the object 
											// (when it exits the scope) and is created invisible
						CREATE_VISIBLE_SAME,// visibility is that which is stored in the template 
											// (does not apply if template not supplied)
						CREATE_VISIBLE,
						CREATE_HIDDEN,};
	Return:
		TRUE for success, otherwise FALSE.
	Example:
		Worksheet	wks;
		BOOL		bRet = wks.Create("c:\\mytemplate.otw", CREATE_VISIBLE_SAME);
		
		Worksheet	newWks;
		if(newWks.Create())
			printf("New wks(%s) is created\n",newWks.GetPage().GetName()); 
	
		Worksheet	TempWks;
		if(TempWks.Create(NULL,CREATE_HIDDEN))
			printf("New hidden wks(%s) is created\n",TempWks.GetPage().GetName());
		
		MatrixLayer mat; // change to MatrixLayer for Matrix 
		if(mat.Create(NULL,CREATE_HIDDEN))
			printf("Hidden matrix %s of %d x %d is created\n",
				mat.GetPage().GetName(), mat.GetNumCols(), mat.GetNumRows());
	SeeAlso:
		Worksheet::CreateCopy			
*/
	BOOL	Create(LPCSTR lpcszTemplate = NULL, int nOption = CREATE_VISIBLE);

/**
		Set the number of rows in a Datasheet including MatixLayers and Worksheets.
	Example: 
		MatrixLayer ml("Matrix1");
		ml.SetNumRows(50);
	Parameters:
		nRows=Input number of rows to set
	Return: 
		Returns TRUE on successful exit and FALSE on failure.
	SeeAlso: 
		Datasheet::GetNumRows, Datasheet::GetNumCols
*/
	BOOL SetNumRows(uint nRows); // Set the number of rows in a Datasheet.
	
#if _OC_VER > 0x0703
	/**#
	Reset Matrix or Worksheet
	Parameters:
		bReduceSize =  in Matrix, reduce to 2x2, in Worksheet, same as ClearWorksheet macro
	Returns:
		TRUE if reset successful
		FALSE otherwise
	Example:
		Worksheet wks("Data1");
		wks.Reset();
	*/
	BOOL	Reset( BOOL bReduceSize = TRUE );
#endif // _OC_VER > 0x0703
};

/** >Internal Origin Objects
		The Worksheet class provides methods and properties common to worksheet layers in
		Origin worksheet pages. An Origin worksheet may contain a number of worksheet columns
		thus the Worksheet class contains a collection of all the columns in the worksheet.
		An Origin C Worksheet object is a wrapper object that is a reference to an internal
		Origin worksheet object. Origin C wrapper objects do not actually exist in Origin and
		merely refer to the internal Origin object. Consequently, multiple Origin C wrapper
		objects can refer to the same internal Origin object. The Worksheet class is derived
		from the Datasheet, Layer, and OriginObject classes from which it inherits methods
		and properties.
	Example:
		Worksheet wks=Project.ActiveLayer();
		if(wks)
		{
			out_int("Num of columns =", wks.GetNumCols());
			while(wks.DeleteCol(0))	 // Remove all columns in worksheet
				;
			ASSERT(wks.GetNumCols() == 0);
		}
		else
			out_str("No active worksheet.");
*/ 
class Worksheet : public Datasheet 
{
public:
/**
	Remarks: 
			Constructor for the Worksheet class that creates a wrapper Worksheet object which is a reference 
			to an internal Origin worksheet object.If the internal origin object is not a worksheet object, 
			then a reference cannot be created. 
	Parameters:
			lpcszWksName = The name of an Origin worksheet object
	Example:
		Worksheet wks("data1");
		if(!wks)
			out_str("There is no such worksheet");
*/
	Worksheet(LPCTSTR lpcszWksName);
/**
	Remarks:
		Worksheet is one of the wrapper objects that is a reference to the actual internal Origin object.
		You can construct a new Worksheet object from another layer object. The worksheet will become invalid if 
		the layer to construct with is actually not a worksheet
	Parameter:
		
	
	Example1:
		Worksheet wks(Project.ActiveLayer());
		if(!wks)
		{
			out_str("The active layer is not a worksheet, or there is nothing in the project");
		}
		else
			printf("Worksheet %s has %d columns\n",wks.GetPage().GetName(),wks.GetNumCols());
	
	
	Example2:
		Worksheet wks1 = Project.ActiveLayer();
		Worksheet wks2(wks1);
		if(!wks2)
		{
			out_str("The active layer is not a worksheet, or there is nothing in the project");
		}
		else
			printf("Worksheet %s has %d columns\n",wks2.GetPage().GetName(),wks2.GetNumCols());
		
*/
	Worksheet(Layer & layer);
	

/**
	Remarks: 
		Attach to an Origin worksheet
	Parameters: 
		lpcszWksName = The name of an Origin worksheet object
	Return: 
		TRUE if the worksheet exists; FALSE if the worksheet does not exist
	Example: 
		Worksheet wks;
		ASSERT(wks.Attach("Data1"));
*/	
	BOOL	Attach(LPCSTR lpcszWksName);		// Attach worksheet object to a real Origin worksheet

/**
	Remarks: 
		Add a new column to the worksheet and name it if specified.
	Parameters: 
		lpcszColName = Optional, Name of column
	Return: 
		The index of the newly added column (0 offset)
	Example: 
		Worksheet wks("data1");
		int colnum = wks.AddCol(); //Add a new column
		colnum = wks.AddCol("Temp"); //Add a new column, called Temp
*/
	int		AddCol(LPCSTR lpcszColName=NULL);	// Return index of newly added column (0 offset) or -1 if add column fails

/**
	Remarks: 
		Add a new column to the worksheet with the given name and store the name in a string. 
		If the given name already exists then increase it.
	Parameters: 
		lpcszColName = desired column name
		strColNameCreated = string to store the actual column name on return
	Return: 
		The index of the newly added column (0 offset)
	Example: 
		Worksheet wks("Data1");
		string str;
		int nCol = wks.AddCol("Temp",str);
		if(nCol >= 0)
			printf("New Column created, name = %s\n",str);
		else
			out_str("Column creation failed");
*/												
	int		AddCol(LPCSTR lpcszColName, string& strColNameCreated); 
																	

/**
	Remarks: 
		This member function is similar to paste text from clipboard into the worksheet
		The data is tab delimited
	Parameters: 
		lpcszText = Tab delimited data values
		nRow = Optional row number to begin the paste
		nCol = Optional column number to begin the paste
		nRepaintMode = Window Refresh mode
	Return: 
		TRUE for success, otherwise FALSE
	Example: 
		Worksheet wks("Data1");
		string str = "1\t2\t3";
		wks.PasteData(str); // append to end of wks from 1st column
*/
	BOOL	PasteData(LPCTSTR lpcszText, // rows of text with tab as list separator and newline of new rows
						int nRow = -1,		// beginning cell's row number, -1 means to append from the first unfilled row of the worksheet
						int nCol = 0,		// beginning cell's column number, -1 if to append from the first unfilled column ( not supported yet)
						int nRepaintMode = 0);// default will use realtime drawing, can disable repaint, or direct repaint 	
		
/**#
*/
	BOOL GetASCIMP(ASCIMP &stAscImp);  
/**#
*/
	BOOL SetASCIMP(ASCIMP &stAscImp);  

//------ CPY 9/24/02 v7.0404 QA70-2658 ASCII_IMPORT_FROM_OC
// requires Origin 7 SR3 or later
/**
    Remarks:
	    Import ASCII file into worksheet by using a ASCIMP struct that will define how to import the data
	Parameters: 
		lpcszFilename = a full path ASCII file name
		stAscImp = An ASCIMP struct that has been setup with import settings
	Return: 
		0 if success, otherwise returns error codes
	Example:
	void test_ascii_import()
	{
		ASCIMP	ascimp;
		string strFile = GetOpenBox("*.dat");
		if(AscImpReadFileStruct(strFile,&ascimp)==0)
		{
			Worksheet wks;
			wks.Create();
			wks.ImportASCII(strFile, ascimp);
		}
	}

*/
	int ImportASCII(LPCSTR lpcszFilename, ASCIMP &stAscImp);  

/**
    Remarks:
	    Import ASCII file into worksheet by using automatic procedure
	Parameters: 
		lpcszFilename = a full path ASCII file name
		bRenameWks = to rename the worksheet to the file name, might need to be fitted for worksheet naming requirement
		nMode = ASCIMP_MODE_REPLACE_DATA, ASCIMP_MODE_APPEND_COLS, ASCIMP_MODE_APPEND_ROWS
		bRenameCols = to rename the columns using labels from the file
	Return: 
		True = succesful; otherwise FALSE
	Example:
	void import_to_active_wks()
	{
		Worksheet wks = Project.ActiveLayer();
		if(wks)
		{
			string strFile = GetOpenBox("*.dat");
			wks.ImportASCII(strFile);
		}
	}

*/
	BOOL ImportASCII(LPCSTR lpcszFilename, BOOL bRenameWks=FALSE, int nMode = ASCIMP_MODE_REPLACE_DATA, BOOL bRenameCols=FALSE);  

/**
	Export worksheet to a ASCII file
	Parameters: 
		lpcszFilename = a full path file name
		dwCntrl = can be the following value(defined in OC_Const.h):
					WKS_EXPORT_HEADING	0x0001	// col name
					WKS_EXPORT_ALL		0x0002	// ignore c1c2r1r2
					WKS_EXPORT_LABELS	0x0004	// col label
					WKS_EXPORT_SELECTED 0x0008	// only selected cols
		lpcszSeparator = the separator in the data file. The default separator is "\t".
		nR1 = first row in the data range to be included with the data file.
		nC1 = first column in the data range to be included with the data file.
		nR2 = last row in the data range to be included with the data file.
		nC2 = last column in the data range to be included with the data file.
	Return: 
		On error, returns -1, otherwise returns the exported file size.
	Example:
	void test_export_ascii()
	{
		Worksheet wks = Project.ActiveLayer();
		if(wks)
		{
			string strFile = GetSaveAsBox("*.dat");
			wks.ExportASCII(strFile, WKS_EXPORT_ALL);
		}
	}

*/
	int ExportASCII(LPCSTR lpcszFilename, DWORD dwCntrl, char cSeparator = '\t', int nR1 = 0, int nC1 = 0, int nR2 = -1, int nC2 = -1);  
	
/**
	Remarks: 
		Insert an empty row in the worksheet 
	Parameters: 
		nPos = Row number with zero offset
	Return: 
		True = succesful; otherwise FALSE
	Example: 
		Worksheet wks("Data1");
		ASSERT(wks.InsertRow(10)); //Insert an empty row on 10th row
	SeeAlso: 
		Worksheet::DeleteRow, Worksheet::AppendRows	
*/	
	BOOL InsertRow(int nPos);
	
/**
	Remarks: 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -