找到自己需要做改变的Excel和Access
为了避免自己以后的,所以第一个步骤看似无关重要,但是却缺一不可。确保Excel中的数据导入数据库不要出错,不然一切白费。
新建数据库,开始执行操作
在数据库上方有一个外部数据,点击外部数据存在一个导入Excel表格功能,点击该功能开始执行导入操作。
找到自己的Excel,明确路径,就可以开始了。点击确定进入下一个步骤
在开始导入的时候,根据自己的需要勾选第一行是否包含标题。
勾选:代表Excel中的第一栏就是数据库中的字段名
不勾选:代表Excel所有的数据会成为数据库中的数据
我以勾选状态演示
在下一个页面,可以根据自己的需要修改字段名称和数据类型。
进入下一页面,可以修改数据库中的主键,可以用Access的默认主键,也可以自定义主键,也可以不要主键。
完成主键的设置过后,就完成了数据的导入,但是还没有完,自己要为导入的数据命名。最后就完成了将Excel中的数据导入到Access数据库中的操作。
以上就是Excel中的数据如何导入到Access数据库中方法介绍,希望能对大家有所帮助!
当描述数据趋势时候,可以采用面积图+折线图的方式实现,为了使得这种呈现方式更加商务和大气,可以按照以下步骤进行处理。
方法/步骤
如图1所示是一组原始的数据,选中这第2列数据,插入折线图,即可获得一张折线图表,但是X轴的数据还没加上,需要选中图表数据后,设计-选择数据-水平轴标签-选中本例中的年份列数据,完成后可得到图2所示折线图。
第1个步骤是为了生成折线图,本步骤是为了生成面积图,如图1所示,再次选择数据列,Ctrl+C拷贝,选中图表区,Ctrl+V粘贴,这时发现一条相同的曲线覆盖了原有曲线,如图2所示。
选中图例2中的数据,更改图表类型-面积图,即可得到粗略的带折线的面积图(图1所示)。
调整坐标轴格式,设置位置坐标轴为在刻度线上,调整后,如图2所示,面积图的起始位置已经与坐标轴对齐重合了。
美化步骤1:设置面积图填充为渐变填充,如下图1所示进行设置。
美化步骤2:设置线条颜色为主题颜色(本例为橙色)
美化步骤3:删除网格线和图例,将纵坐标轴的刻度设为无,可得到图2所示效果,图表基本已经成型。最后再设置一下图表区背景颜色为浅灰,得到图3所示效果。
美化步骤4:适当加上一些数据点标签,文本框,标题等,形成风格,如下图所示成图。
以上就是excel图表如何制作商务范的加粗边缘面积图方法介绍,希望能对大家有所帮助!
excel中lookup查找函数用法详细步骤实例,函数的工作原理是在第二个参数(区(m.tulaoshi.com)域,一般是一列)中查找第一个参数(一般为单元格值),找到首个大于第一个参数时,函数返回找到的上方位置,对应的第三个参数的值。
如果第二个参数升序排列,可以直接说是返回小于等于第一个参数的最大值。
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/ejc/)一般情况下都需要将第二个参数升序排列,函数才有现实意义。
方法/步骤
如图红框内部是不同的身高区间对应的尺码型号。
在红框所示的单元格内输入=lookup(),当光标在括号外部闪烁时,鼠标点一下括号内部,此时光标会在括号内部闪烁。
此时光标在内部闪动,编辑栏下面出现函数参数提示框,这里提示函数有两种结构,一种是包含三个参数的向量型,一种是包含两个参数的数组型,这里我们要用向量型继续演示。
光标在括号内部闪动之后用鼠标点选一下红框所示的f2单元格,然后输入一个半角逗号。
输入完半角逗号,用鼠标左键点住N3单元格不放手,向下拖动到N9单元格松手,也就是选中身高区间所在区域,然后在输入一个半角逗号。
输入完半角逗号之后,再次用鼠标点住p3单元格向下拖动到P9单元格,也就是几种型号所在区域
鼠标点一下函数括号内第一个逗号之后的位置,然后按下鼠标拖动到后面的括号之前,然后按f4,知道字母和数字之前有美元符号。
出现美元符号之后,点一下对号,或者回车,完成函数的输入。
拖动填充柄向下填充公式,此时函数的返回值就是该行身高所对应的尺码。
以上就是excel中函数lookup查询函数用法详细步骤实例,希望能对大家有所帮助!
这篇文章主要介绍了使用PHPExcel操作Excel用法,实例分析了使用PHPExcel进行读写及生成等常用技巧,非常具有实用价值,需要的朋友可以参考下
&ntuLaoShi.combsp;本文实例分析了使用PHPExcel操作Excel用法。分享给大家供大家参考。具体分析如下:
PHPExcel下载地址:
http://www.codeplex.com/PHPExcel
http://www.phpexcel.net
开发包Tests目录有详细使用实例 支持中文,注意文件编码 文件保存为utf-8
1.header部分:
? 1234 header("Content-Type:application/vnd.ms-excel");header("Content-Disposition:attachment;filename=sample.xls");header("Pragma:no-cache");header("Expires:0");2.写excel:
? 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 //Include classrequire_once('Classes/PHPExcel.php');require_once('Classes/PHPExcel/Writer/Excel2007.php');$objPHPExcel = new PHPExcel(); //Set properties 设置文件属性$objPHPExcel-getProperties()-setCreator("Maarten Balliauw");$objPHPExcel-getProperties()-setLastModifiedBy("Maarten Balliauw");$objPHPExcel-getProperties()-setTitle("Office 2007 XLSX Test Document");$objPHPExcel-getProperties()-setSubject("Office 2007 XLSX Test Document");$objPHPExcel-getProperties()-setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");$objPHPExcel-getProperties()-setKeywords("office 2007 openxml php");$objPHPExcel-getProperties()-setCategory("Test result file"); //Add some data 添加数据$objPHPExcel-setActiveSheetIndex(0);$objPHPExcel-getActiveSheet()-setCellValue('A1', 'Hello');//可以指定位置$objPHPExcel-getActiveSheet()-setCellValue('A2', true);$objPHPExcel-getActiveSheet()-setCellValue('A3', false);$objPHPExcel-getActiveSheet()-setCellValue('B2', 'world!');$objPHPExcel-getActiveSheet()-setCellValue('B3', 2);$objPHPExcel-getActiveSheet()-setCellValue('C1', 'Hello');$objPHPExcel-getActiveSheet()-setCellValue('D2', 'world!'); //循环for($i = 1;$i200;$i++) {$objPHPExcel-getActiveSheet()-setCellValue('A' . $i, $i);$objPHPExcel-getActiveSheet()-setCellValue('B' . $i, 'Test value');} //日期格式化$objPHPExcel-getActiveSheet()-setCellValue('D1', time());$objPHPExcel-getActiveSheet()-getStyle('D1')-getNumberFormat()-setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDDSLASH); //Add comment 添加注释$objPHPExcel-getActiveSheet()-getComment('E11')-setAuthor('PHPExcel');$objCommentRichText = $objPHPExcel-getActiveSheet()-getComment('E11')-getText()-createTextRun('PHPExcel:');$objCommentRichText-getFont()-setBold(true);$objPHPExcel-getActiveSheet()-getComment('E11')-getText()-createTextRun("rn");$objPHPExcel-getActiveSheet()-getComment('E11')-getText()-createTextRun('Total amount on the current invoice, excluding VAT.'); //Add rich-text string 添加文字 可设置样式$objRichText = new PHPExcel_RichText( $objPHPExcel-getActiveSheet()-getCell('A18') );$objRichText-createText('This invoice is ');$objPayable = $objRichText-createTextRun('payable within thirty days after the end of the month');$objPayable-getFont()-setBold(true);$objPayable-getFont()-setItalic(true);$objPayable-getFont()-setColor( new PHPExcel_Style_Color( PHPExcel_Style_Color::COLOR_DARKGREEN ) );$objRichText-createText(', unless specified otherwise on the invoice.'); //Merge cells 合并分离单元格$objPHPExcel-getActiveSheet()-mergeCells('A18:E22');$objPHPExcel-getActiveSheet()-unmergeCells('A18:E22'); //Protect cells 保护单元格$objPHPExcel-getActiveSheet()-getProtection()-setSheet(true);//Needs to be set to true in order to enable any worksheet protection!$objPHPExcel-getActiveSheet()-protectCells('A3:E13', 'PHPExcel'); //Set cell number formats 数字格式化$objPHPExcel-getActiveSheet()-getStyle('E4')-getNumberFormat()-setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);$objPHPExcel-getActiveSheet()-duplicateStyle( $objPHPExcel-getActiveSheet()-getStyle('E4'), 'E5:E13' ); //Set column widths 设置列宽度$objPHPExcel-getActiveSheet()-getColumnDimension('B')-setAutoSize(true);$objPHPExcel-getActiveSheet()-getColumnDimension('D')-setWidth(12); //Set fonts 设置字体$objPHPExcel-getActiveSheet()-getStyle('B1')-getFont()-setName('Candara');$objPHPExcel-getActiveSheet()-getStyle('B1')-getFont()-setSize(20);$objPHPExcel-getActiveSheet()-getStyle('B1')-getFont()-setBold(true);$objPHPExcel-getActiveSheet()-getStyle('B1')-getFont()-setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);$objPHPExcel-getActiveSheet()-getStyle('B1')-getFont()-getColor()-setARGB(PHPExcel_Style_Color::COLOR_WHITE); //Set alignments 设置对齐$objPHPExcel-getActiveSheet()-getStyle('D11')-getAlignment()-setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);$objPHPExcel-getActiveSheet()-getStyle('A18')-getAlignment()-setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY);$objPHPExcel-getActiveSheet()-getStyle('A18')-getAlignment()-setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);$objPHPExcel-getActiveSheet()-getStyle('A3')-getAlignment()-setWrapText(true); //Set column borders 设置列边框$objPHPExcel-getActiveSheet()-getStyle('A4')-getBorders()-getTop()-setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);$objPHPExcel-getActiveSheet()-getStyle('A10')-getBorders()-getLeft()-setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);$objPHPExcel-getActiveSheet()-getStyle('E10')-getBorders()-getRight()-setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);$objPHPExcel-getActiveSheet()-getStyle('D13')-getBorders()-getLeft()-setBorderStyle(PHPExcel_Style_Border::BORDER_THICK);$objPHPExcel-getActiveSheet()-getStyle('E13')-getBorders()-getBottom()-setBorderStyle(PHPExcel_Style_Border::BORDER_THICK); //Set border colors 设置边框颜色$objPHPExcel-getActiveSheet()-getStyle('D13')-getBorders()-getLeft()-getColor()-setARGB('FF993300');$objPHPExcel-getActiveSheet()-getStyle('D13')-getBorders()-getTop()-getColor()-setARGB('FF993300');$objPHPExcel-getActiveSheet()-getStyle('D13')-getBorders()-getBottom()-getColor()-setARGB('FF993300');$objPHPExcel-getActiveSheet()-getStyle('E13')-getBorders()-getRight()-getColor()-setARGB('FF993300'); //Set fills 设置填充$objPHPExcel-getActiveSheet()-getStyle('A1')-getFill()-setFillType(PHPExcel_Style_Fill::FILL_SOLID);$objPHPExcel-getActiveSheet()-getStyle('A1')-getFill()-getStartColor()-setARGB('FF808080'); //Add a hyperlink to the sheet 添加链接$objPHPExcel-getActiveSheet()-setCellValue('E26', 'www.phpexcel.net');$objPHPExcel-getActiveSheet()-getCell('E26')-getHyperlink()-setUrl('http://www.phpexcel.net');$objPHPExcel-getActiveSheet()-getCell('E26')-getHyperlink()-setTooltip('Navigate to website');$objPHPExcel-getActiveSheet()-getStyle('E26')-getAlignment()-setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); //Add a drawing to the worksheet 添加图片$objDrawing = new PHPExcel_Worksheet_Drawing();$objDrawing-setName('Logo');$objDrawing-setDescription('Logo');$objDrawing-setPath('./images/officelogo.jpg');$objDrawing-setHeight(36);$objDrawing-setCoordinates('B15');$objDrawing-setOffsetX(110);$objDrawing-setRotation(25);$objDrawing-getShadow()-setVisible(true);$objDrawing-getShadow()-setDirection(45);$objDrawing-setWorksheet($objPHPExcel-getActiveSheet()); //Play around with inserting and removing rows and columns$objPHPExcel-getActiveSheet()-insertNewRowBefore(6, 10);$objPHPExcel-getActiveSheet()-removeRow(6, 10);$objPHPExcel-getActiveSheet()-insertNewColumnBefore('E', 5);$objPHPExcel-getActiveSheet()-removeColumn('E', 5); //Add conditional formatting$objConditional1 = new PHPExcel_Style_Conditional();$objConditional1-setConditionType(PHPExcel_Style_Conditional::CONDITION_CELLIS);$objConditional1-setOperatorType(PHPExcel_Style_Conditional::OPERATOR_LESSTHAN);$objConditional1-setCondition('0');$objConditional1-getStyle()-getFont()-getColor()-setARGB(PHPExcel_Style_Color::COLOR_RED);$objConditional1-getStyle()-getFont()-setBold(true); //Set autofilter 自动过滤$objPHPExcel-getActiveSheet()-setAutoFilter('A1:C9'); //Hide "Phone" and "fax" column 隐藏列$objPHPExcel-getActiveSheet()-getColumnDimension('C')-setVisible(false);$objPHPExcel-getActiveSheet()-getColumnDimension('D')-setVisible(false); //Set document security 设置文档安全$objPHPExcel-getSecurity()-setLockWindows(true);$objPHPExcel-getSecurity()-setLockStructure(true);$objPHPExcel-getSecurity()-setWorkbookPassword("PHPExcel"); //Set sheet security 设置工作表安全$objPHPExcel-getActiveSheet()-getProtection()-setPassword('PHPExcel');$objPHPExcel-getActiveSheet()-getProtection()-setSheet(true);// This should be enabled in order to enable any of the following!$objPHPExcel-getActiveSheet()-getProtection()-setSort(true);$objPHPExcel-getActiveSheet()-getProtection()-setInsertRows(true);$objPHPExcel-getActiveSheet()-getProtection()-setFormatCells(true); //Calculated data 计算echo 'Value of B14 [=COUNT(B2:B12)]: ' . $objPHPExcel-getActiveSheet()-getCell('B14')-getCalculatedValue() . "rn"; //Set outline levels$objPHPExcel-getActiveSheet()-getColumnDimension('E')-setOutlineLevel(1);$objPHPExcel-getActiveSheet()-getColumnDimension('E')-setVisible(false);$objPHPExcel-getActiveSheet()-getColumnDimension('E')-setCollapsed(true); //Freeze panes$objPHPExcel-getActiveSheet()-freezePane('A2'); //Rows to repeat at top$objPHPExcel-getActiveSheet()-getPageSetup()-setRowsToRepeatAtTopByStartAndEnd(1, 1); //Set data validation 验证输入值$objValidation = $objPHPExcel-getActiveSheet()-getCell('B3')-getDataValidation();$objValidation-setType( PHPExcel_Cell_DataValidation::TYPE_WHOLE );$objValidation-setErrorStyle( PHPExcel_Cell_DataValidation::STYLE_STOP );$objValidation-setAllowBlank(true);$objValidation-setShowInputMessage(true);$objValidation-setShowErrorMessage(true);$objValidation-setErrorTitle('Input error');$objValidation-setError('Number is not allowed!');$objValidation-setPromptTitle('Allowed input');$objValidation-setPrompt('Only numbers between 10 and 20 are allowed.');$objValidation-setFormula1(10);$objValidation-setFormula2(20);$objPHPExcel-getActiveSheet()-getCell('B3')-setDataValidation($objValidation); //Create a new worksheet, after the default sheet 创建新的工作标签$objPHPExcel-createSheet();$objPHPExcel-setActiveSheetIndex(1); //Set header and footer. When no different headers for odd/even are used, odd header is assumed. 页眉页脚$objPHPExcel-getActiveSheet()-getHeaderFooter()-setOddHeader('&C&HPlease treat this document as confidential!');$objPHPExcel-getActiveSheet()-getHeaderFooter()-setOddFooter('&L&B' . $objPHPExcel-getProperties()-getTitle() . '&RPage &P of &N'); //Set page orientation and size 方向大小$objPHPExcel-getActiveSheet()-getPageSetup()-setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);$objPHPExcel-getActiveSheet()-getPageSetup()-setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4); //Rename sheet 重命名工作表标签$objPHPExcel-getActiveSheet()-setTitle('Simple'); //Set active sheet index to the first sheet, so Excel opens this as the first sheet$objPHPExcel-setActiveSheetIndex(0); //Save Excel 2007 file 保存$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);$objWriter-save(str_replace('.php', '.xlsx', __FILE__)); //Save Excel 5 file 保存require_once('Classes/PHPExcel/Writer/Excel5.php');$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);$objWriter-save(str_replace('.php', '.xls', __FILE__)); //1.6.2新版保存require_once('Classes/PHPExcel/IOFactory.php');$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');$objWriter-save(str_replace('.php', '.xls', __FILE__));3.读excel
? 1234 //Include classrequire_once('Classes/PHPExcel/Reader/Excel2007.php');$objReader = new PHPExcel_Reader_Excel2007;$objPHPExcel = $objReader-load("05featuredemo.xlsx");4.读写csv
? 123456789101112131415161718192021 require_once("05featuredemo.inc.php");require_once('Classes/PHPExcel/Writer/CSV.php');require_once('Classes/PHPExcel/Reader/CSV.php');require_once('Classes/PHPExcel/Writer/Excel2007.php');//Write to CSV format 写$objWriter = new PHPExcel_Writer_CSV($objPHPExcel);$objWriter-setDelimiter(';');$objWriter-setEnclosure('');$objWriter-setLineEnding("rn");$objWriter-setSheetIndex(0);$objWriter-save(str_replace('.php', '.csv', __FILE__));//Read from CSV format 读$objReader = new PHPExcel_Reader_CSV();$objReader-setDelimiter(';');$objReader-setEnclosure('');$objReader-setLineEnding("rn");$objReader-setSheetIndex(0);$objPHPExcelFromCSV = $objReader-load(str_replace('.php', '.csv', __FILE__));//Write to Excel2007 format$objWriter2007 = new PHPExcel_Writer_Excel2007($objPHPExcelFromCSV);$objWriter2007-save(str_replace('.php', '.xlsx', __FILE__));5.写html
? 123456 require_once("05featuredemo.inc.php");require_once('Classes/PHPExcel/Writer/HTML.php');//Write to HTML format$objWriter = new PHPExcel_Writer_HTML($objPHPExcel);$objWriter-setSheetIndex(0);$objWriter-save(str_replace('.php', '.htm', __FILE__));6.写pdf
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/ejc/)? 12345678 require_once("05featuredemo.inc.php");require_once('Classes/PHPExcel/IOFactory.php');//Write to PDF format$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');$objWriter-setSheetIndex(0);$objWriter-save(str_replace('.php', '.pdf', __FILE__));//Echo memory peak usageecho date('H:i:s')." Peak memory usage: ".(memory_get_peak_usage(true) / 1024 / 1024)." MBrn";
希望本文所述对大家的php程序设计有所帮助。