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

📄 readfmt.java

📁 关于生成EXCEL文件的封装类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				((Vector)map.get( "head_rownum" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "head_rownum" ) ).add( "" );
			}
		}
	}
	
	private void get_tr( Element addr )
	{
		String stmp = "";
		
		map.put( "tr_value", new Vector() );
		map.put( "tr_align", new Vector() );
		map.put( "tr_size", new Vector() );
		map.put( "tr_font", new Vector() );
		map.put( "tr_local_x", new Vector() );
		map.put( "tr_local_y", new Vector() );
		map.put( "tr_height", new Vector() );
		map.put( "tr_colspan", new Vector() );
		map.put( "tr_rowspan", new Vector() );
		
		NodeList tr = addr.getElementsByTagName("tr");
		for ( int j=0; j<tr.getLength(); j++ )
		{
			Element e = (Element) tr.item(j);
			Text t = (Text) e.getFirstChild();
			
			stmp = t.getNodeValue();
			if( null != stmp || !"".equals( stmp ) )
			{
				((Vector)map.get( "tr_value" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "tr_value" ) ).add( "&nbsp;" );
			}
			stmp = e.getAttribute( "align" );
			if( null != stmp )
			{
				((Vector)map.get( "tr_align" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "tr_align" ) ).add( "" );
			}
			stmp = e.getAttribute( "size" );
			if( null != stmp )
			{
				((Vector)map.get( "tr_size" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "tr_size" ) ).add( "" );
			}
			stmp = e.getAttribute( "font" );
			if( null != stmp )
			{
				((Vector)map.get( "tr_font" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "tr_font" ) ).add( "" );
			}
			stmp = e.getAttribute( "local_x" );
			if( null != stmp )
			{
				((Vector)map.get( "tr_local_x" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "tr_local_x" ) ).add( "" );
			}
			stmp = e.getAttribute( "local_y" );
			if( null != stmp )
			{
				((Vector)map.get( "tr_local_y" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "tr_local_y" ) ).add( "" );
			}
			stmp = e.getAttribute( "height" );
			if( null != stmp )
			{
				((Vector)map.get( "tr_height" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "tr_height" ) ).add( "" );
			}
			stmp = e.getAttribute( "colspan" );
			if( null != stmp )
			{
				((Vector)map.get( "tr_colspan" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "tr_colspan" ) ).add( "" );
			}
			stmp = e.getAttribute( "rowspan" );
			if( null != stmp )
			{
				((Vector)map.get( "tr_rowspan" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "tr_rowspan" ) ).add( "" );
			}
		}
	}
	
	private void get_body( Element addr )
	{
		String stmp = "";
		
		map.put( "body_value", new Vector() );
		map.put( "body_align", new Vector() );
		map.put( "body_size", new Vector() );
		map.put( "body_font", new Vector() );
		map.put( "body_local_x", new Vector() );
		map.put( "body_local_y", new Vector() );
		map.put( "body_height", new Vector() );
		
		NodeList body = addr.getElementsByTagName("body");
		for ( int j=0; j<body.getLength(); j++ )
		{
			Element e = (Element) body.item(j);
			
			stmp = e.getAttribute( "value" );
			if( null != stmp || !"".equals( stmp ) )
			{
				((Vector)map.get( "body_value" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "body_value" ) ).add( "&nbsp;" );
			}
			stmp = e.getAttribute( "align" );
			if( null != stmp )
			{
				((Vector)map.get( "body_align" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "body_align" ) ).add( "" );
			}
			stmp = e.getAttribute( "size" );
			if( null != stmp )
			{
				((Vector)map.get( "body_size" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "body_size" ) ).add( "" );
			}
			stmp = e.getAttribute( "font" );
			if( null != stmp )
			{
				((Vector)map.get( "body_font" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "body_font" ) ).add( "" );
			}
			stmp = e.getAttribute( "local_x" );
			if( null != stmp )
			{
				((Vector)map.get( "body_local_x" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "body_local_x" ) ).add( "" );
			}
			stmp = e.getAttribute( "local_y" );
			if( null != stmp )
			{
				((Vector)map.get( "body_local_y" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "body_local_y" ) ).add( "" );
			}
			stmp = e.getAttribute( "height" );
			if( null != stmp )
			{
				((Vector)map.get( "body_height" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "body_height" ) ).add( "" );
			}
		}
	}
	
	private void get_totle( Element addr )
	{
		String stmp = "";
		
		map.put( "totle_value", new Vector() );
		map.put( "totle_align", new Vector() );
		map.put( "totle_size", new Vector() );
		map.put( "totle_font", new Vector() );
		map.put( "totle_local_x", new Vector() );
		map.put( "totle_local_y", new Vector() );
		map.put( "totle_row", new Vector() );
		map.put( "totle_height", new Vector() );
		
		NodeList totle = addr.getElementsByTagName("totle");
		for ( int j=0; j<totle.getLength(); j++ )
		{
			Element e = (Element) totle.item(j);
			Text t = (Text) e.getFirstChild();
			
			stmp = t.getNodeValue();
			if( null != stmp || !"".equals( stmp ) )
			{
				((Vector)map.get( "totle_value" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "totle_value" ) ).add( "&nbsp;" );
			}
			stmp = e.getAttribute( "align" );
			if( null != stmp )
			{
				((Vector)map.get( "totle_align" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "totle_align" ) ).add( "" );
			}
			stmp = e.getAttribute( "size" );
			if( null != stmp )
			{
				((Vector)map.get( "totle_size" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "totle_size" ) ).add( "" );
			}
			stmp = e.getAttribute( "font" );
			if( null != stmp )
			{
				((Vector)map.get( "totle_font" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "totle_font" ) ).add( "" );
			}
			stmp = e.getAttribute( "local_x" );
			if( null != stmp )
			{
				((Vector)map.get( "totle_local_x" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "totle_local_x" ) ).add( "" );
			}
			stmp = e.getAttribute( "local_y" );
			if( null != stmp )
			{
				((Vector)map.get( "totle_local_y" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "totle_local_y" ) ).add( "" );
			}
			stmp = e.getAttribute( "row" );
			if( null != stmp )
			{
				((Vector)map.get( "totle_row" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "totle_row" ) ).add( "" );
			}
			stmp = e.getAttribute( "height" );
			if( null != stmp )
			{
				((Vector)map.get( "totle_height" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "totle_height" ) ).add( "" );
			}
		}
	}
	
	private void get_bottom( Element addr )
	{
		String stmp = "";
		
		map.put( "bottom_value", new Vector() );
		map.put( "bottom_align", new Vector() );
		map.put( "bottom_size", new Vector() );
		map.put( "bottom_font", new Vector() );
		map.put( "bottom_local_x", new Vector() );
		map.put( "bottom_local_y", new Vector() );
		map.put( "bottom_height", new Vector() );
		map.put( "bottom_datefmt", new Vector() );
		
		NodeList bottom = addr.getElementsByTagName("bottom");
		for ( int j=0; j<bottom.getLength(); j++ )
		{
			Element e = (Element) bottom.item(j);
			Text t = (Text) e.getFirstChild();
			
			try
			{
				stmp = t.getNodeValue();
			}
			catch( NullPointerException ne )
			{
				stmp = e.getAttribute( "value" );
			}
			catch( Exception ex )
			{
				stmp = "&nbsp;";
			}
			if( null != stmp || !"".equals( stmp ) )
			{
				((Vector)map.get( "bottom_value" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "bottom_value" ) ).add( "&nbsp;" );
			}
			stmp = e.getAttribute( "align" );
			if( null != stmp )
			{
				((Vector)map.get( "bottom_align" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "bottom_align" ) ).add( "" );
			}
			stmp = e.getAttribute( "size" );
			if( null != stmp )
			{
				((Vector)map.get( "bottom_size" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "bottom_size" ) ).add( "" );
			}
			stmp = e.getAttribute( "font" );
			if( null != stmp )
			{
				((Vector)map.get( "bottom_font" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "bottom_font" ) ).add( "" );
			}
			stmp = e.getAttribute( "local_x" );
			if( null != stmp )
			{
				((Vector)map.get( "bottom_local_x" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "bottom_local_x" ) ).add( "" );
			}
			stmp = e.getAttribute( "local_y" );
			if( null != stmp )
			{
				((Vector)map.get( "bottom_local_y" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "bottom_local_y" ) ).add( "" );
			}
			stmp = e.getAttribute( "height" );
			if( null != stmp )
			{
				((Vector)map.get( "bottom_height" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "bottom_height" ) ).add( "" );
			}
			stmp = e.getAttribute( "datefmt" );
			if( null != stmp || !"".equals( stmp ) )
			{
				((Vector)map.get( "bottom_datefmt" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "bottom_datefmt" ) ).add( "yyyy-MM-dd" );
			}
		}
	}
	
	private void get_list( Element addr ) throws ZAppException
	{
		String stmp = "";
		int num = 0;
		
		map.put( "list_value", new Vector() );
		map.put( "list_align", new Vector() );
		map.put( "list_size", new Vector() );
		map.put( "list_font", new Vector() );
		map.put( "list_local_x", new Vector() );
		map.put( "list_local_y", new Vector() );
		map.put( "list_height", new Vector() );
		map.put( "list_colspan", new Vector() );
		map.put( "list_rowspan", new Vector() );
		map.put( "list_num", new Vector() );
		
		NodeList list = addr.getElementsByTagName("list");
		
		//列表中num代表了条数,在生成时根据num为条数的依据
		//for ( int j=0; j<list.getLength(); j++ )
		num = list.getLength();
		num = num > 0 ? 1 : 0; 

		for( int j=0; j<num; j++ )
		{
			Element e = (Element) list.item(j);
			
			stmp = e.getAttribute( "value" );
			if( null != stmp || !"".equals( stmp ) )
			{
				((Vector)map.get( "list_value" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "list_value" ) ).add( "&nbsp;" );
			}
			stmp = e.getAttribute( "align" );
			if( null != stmp )
			{
				((Vector)map.get( "list_align" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "list_align" ) ).add( "" );
			}
			stmp = e.getAttribute( "size" );
			if( null != stmp )
			{
				((Vector)map.get( "list_size" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "list_size" ) ).add( "" );
			}
			stmp = e.getAttribute( "font" );
			if( null != stmp )
			{
				((Vector)map.get( "list_font" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "list_font" ) ).add( "" );
			}
			stmp = e.getAttribute( "local_x" );
			if( null != stmp )
			{
				((Vector)map.get( "list_local_x" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "list_local_x" ) ).add( "" );
			}
			stmp = e.getAttribute( "local_y" );
			if( null != stmp )
			{
				((Vector)map.get( "list_local_y" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "list_local_y" ) ).add( "" );
			}
			stmp = e.getAttribute( "height" );
			if( null != stmp )
			{
				((Vector)map.get( "list_height" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "list_height" ) ).add( "" );
			}
			stmp = e.getAttribute( "colspan" );
			if( null != stmp )
			{
				((Vector)map.get( "list_colspan" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "list_colspan" ) ).add( "" );
			}
			stmp = e.getAttribute( "rowspan" );
			if( null != stmp )
			{
				((Vector)map.get( "list_rowspan" ) ).add( stmp );
			}
			else
			{
				((Vector)map.get( "list_rowspan" ) ).add( "" );
			}
			stmp = e.getAttribute( "num" );
			if( null != stmp )
			{
				((Vector)map.get( "list_num" ) ).add( stmp );
			}
			else
			{
				//初始化为25条
				((Vector)map.get( "list_num" ) ).add( "25" );
			}
		}
	}
}

⌨️ 快捷键说明

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