-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
334 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{86363AAC-22D9-4523-8DC0-A3BECBE90C06}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>Framework发票</RootNamespace> | ||
<AssemblyName>Framework发票</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
<PublishUrl>publish\</PublishUrl> | ||
<Install>true</Install> | ||
<InstallFrom>Disk</InstallFrom> | ||
<UpdateEnabled>false</UpdateEnabled> | ||
<UpdateMode>Foreground</UpdateMode> | ||
<UpdateInterval>7</UpdateInterval> | ||
<UpdateIntervalUnits>Days</UpdateIntervalUnits> | ||
<UpdatePeriodically>false</UpdatePeriodically> | ||
<UpdateRequired>false</UpdateRequired> | ||
<MapFileExtensions>true</MapFileExtensions> | ||
<ApplicationRevision>0</ApplicationRevision> | ||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> | ||
<IsWebBootstrapper>false</IsWebBootstrapper> | ||
<UseApplicationTrust>false</UseApplicationTrust> | ||
<BootstrapperEnabled>true</BootstrapperEnabled> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<COMReference Include="Microsoft.Office.Core"> | ||
<Guid>{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}</Guid> | ||
<VersionMajor>2</VersionMajor> | ||
<VersionMinor>8</VersionMinor> | ||
<Lcid>0</Lcid> | ||
<WrapperTool>primary</WrapperTool> | ||
<Isolated>False</Isolated> | ||
<EmbedInteropTypes>True</EmbedInteropTypes> | ||
</COMReference> | ||
<COMReference Include="Microsoft.Office.Interop.Excel"> | ||
<Guid>{00020813-0000-0000-C000-000000000046}</Guid> | ||
<VersionMajor>1</VersionMajor> | ||
<VersionMinor>9</VersionMinor> | ||
<Lcid>0</Lcid> | ||
<WrapperTool>primary</WrapperTool> | ||
<Isolated>False</Isolated> | ||
<EmbedInteropTypes>True</EmbedInteropTypes> | ||
</COMReference> | ||
<COMReference Include="VBIDE"> | ||
<Guid>{0002E157-0000-0000-C000-000000000046}</Guid> | ||
<VersionMajor>5</VersionMajor> | ||
<VersionMinor>3</VersionMinor> | ||
<Lcid>0</Lcid> | ||
<WrapperTool>primary</WrapperTool> | ||
<Isolated>False</Isolated> | ||
<EmbedInteropTypes>True</EmbedInteropTypes> | ||
</COMReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2"> | ||
<Visible>False</Visible> | ||
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 和 x64%29</ProductName> | ||
<Install>true</Install> | ||
</BootstrapperPackage> | ||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> | ||
<Visible>False</Visible> | ||
<ProductName>.NET Framework 3.5 SP1</ProductName> | ||
<Install>false</Install> | ||
</BootstrapperPackage> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29911.84 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework发票", "Framework发票.csproj", "{86363AAC-22D9-4523-8DC0-A3BECBE90C06}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{86363AAC-22D9-4523-8DC0-A3BECBE90C06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{86363AAC-22D9-4523-8DC0-A3BECBE90C06}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{86363AAC-22D9-4523-8DC0-A3BECBE90C06}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{86363AAC-22D9-4523-8DC0-A3BECBE90C06}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {D0D58A98-7A0D-4B30-BB10-87CADD986AD9} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
using System; | ||
using Excel = Microsoft.Office.Interop.Excel; | ||
using System.IO; | ||
using System.Text; | ||
|
||
|
||
namespace FrameWork发票 | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
ExcelOp eo = new ExcelOp(); | ||
//Console.WriteLine("请输入税控盘持有人姓名:"); | ||
|
||
|
||
Console.WriteLine("请讲文件拖入此处(文件的名称格式为:xx商品编码,xx为税控盘名称!且软件运行后生成的excel文件在 《文档》 文件夹中)\n"); | ||
string fullname = Console.ReadLine(); | ||
|
||
Console.WriteLine("\n正在转换中,请耐心等待。。。"); | ||
string name = fullname.Substring(fullname.IndexOf(".") - 6,6); | ||
eo.CreateExcelFile(name); | ||
object Nothing = System.Reflection.Missing.Value; | ||
Excel.Application app = new Excel.Application(); | ||
app.Visible = false; | ||
|
||
//string item = eo.Read(string.Format("E://个人文件//妈妈//{0}商品编码.txt",name)); | ||
string item = eo.Read(fullname); | ||
int i = item.IndexOf("<BMXX>"); | ||
int i_ = item.IndexOf("</BMXX>"); | ||
try | ||
{ | ||
while (i != -1) | ||
{ | ||
Excel.Workbook mybook = app.Workbooks.Open(name, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing); | ||
Excel.Worksheet mysheet = (Excel.Worksheet)mybook.Worksheets[1]; | ||
int i1 = item.IndexOf("<SPMC>"); | ||
int i1_ = item.IndexOf("</SPMC>"); | ||
int i2 = item.IndexOf("<SPBM>"); | ||
int i2_ = item.IndexOf("</SPBM>"); | ||
int i3 = item.IndexOf("<JM>"); | ||
int i3_ = item.IndexOf("</JM>"); | ||
int i4 = item.IndexOf("<SPBMJC>"); | ||
int i4_ = item.IndexOf("</SPBMJC>"); | ||
int i5 = item.IndexOf("<ZZSSL>"); | ||
int i5_ = item.IndexOf("</ZZSSL>"); | ||
int i6 = item.IndexOf("<GGXH>"); | ||
int i6_ = item.IndexOf("</GGXH>"); | ||
int i7 = item.IndexOf("<JLDW>"); | ||
int i7_ = item.IndexOf("</JLDW>"); | ||
int i8 = item.IndexOf("<KYSL>"); | ||
int i8_ = item.IndexOf("</KYSL>"); | ||
int i9 = item.IndexOf("<HSBZ>"); | ||
int i9_ = item.IndexOf("</HSBZ>"); | ||
int i10 = item.IndexOf("<YH>");//优惠政策类型 | ||
int i10_ = item.IndexOf("</YH>"); | ||
int i11 = item.IndexOf("<SYPC>");//免税类型 | ||
int i11_ = item.IndexOf("</SYPC>"); | ||
|
||
string c1 = item.Substring(i1 + 6, i1_ - i1 - 6); | ||
string c2 = item.Substring(i2 + 6, i2_ - i2 - 6); | ||
string c3 = item.Substring(i3 + 4, i3_ - i3 - 4); | ||
string c4 = item.Substring(i4 + 8, i4_ - i4 - 8); | ||
string c5 = item.Substring(i5 + 7, i5_ - i5 - 7); | ||
string c6 = item.Substring(i6 + 6, i6_ - i6 - 6); | ||
string c7 = item.Substring(i7 + 6, i7_ - i7 - 6); | ||
string c8 = item.Substring(i8 + 6, i8_ - i8 - 6); | ||
string c9 = item.Substring(i9 + 6, i9_ - i9 - 6); | ||
string c10 = item.Substring(i10 + 4, i10_ - i10 - 4); | ||
string c11 = item.Substring(i11 + 6, i11_ - i11 - 6); | ||
eo.WriteToExcel("全部商品", c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, mybook, mysheet, Nothing, app); | ||
item = item.Remove(0, i_ + 7); | ||
i = item.IndexOf("<BMXX>"); | ||
i_ = item.IndexOf("</BMXX>"); | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(e.Message); | ||
} | ||
finally | ||
{ | ||
Console.WriteLine("\n转换完成!请在‘我的文档’中查找点击!输入回车自动退出。"); | ||
Console.ReadKey(); | ||
app.Quit(); | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
} | ||
class ExcelOp | ||
{ | ||
public string Read(string path) | ||
{ | ||
StreamReader sr = new StreamReader(path, Encoding.UTF8); | ||
return sr.ReadToEnd(); | ||
} | ||
|
||
internal void CreateExcelFile(string FileName) | ||
{ | ||
//create | ||
object Nothing = System.Reflection.Missing.Value; | ||
var app = new Excel.Application(); | ||
app.Visible = false; | ||
Excel.Workbook workBook = app.Workbooks.Add(Nothing); | ||
Excel.Worksheet worksheet = (Excel.Worksheet)workBook.Sheets[1]; | ||
|
||
worksheet.Name = FileName; | ||
//headline | ||
worksheet.Cells[1, 1] = "名称"; | ||
worksheet.Cells[1, 2] = "编码"; | ||
//worksheet.Cells[1, 2].numberFormatting = "@"; | ||
worksheet.Cells[1, 3] = "简码"; | ||
worksheet.Cells[1, 4] = "税收分类简称"; | ||
worksheet.Cells[1, 5] = "税率"; | ||
//worksheet.Cells[1, 5].numberFormatting = "formatnumber"; | ||
worksheet.Cells[1, 6] = "规格/厂牌"; | ||
worksheet.Cells[1, 7] = "计量单位"; | ||
worksheet.Cells[1, 8] = "适用税率"; | ||
worksheet.Cells[1, 9] = "含税标志"; | ||
worksheet.Cells[1, 10] = "优惠政策类型"; | ||
worksheet.Cells[1, 11] = "免税类型"; | ||
|
||
worksheet.Columns[2].NumberFormatLocal = "@";//设置第二列为 文本格式 | ||
|
||
worksheet.SaveAs(FileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing); | ||
workBook.Close(false, Type.Missing, Type.Missing); | ||
|
||
|
||
app.Quit(); | ||
|
||
} | ||
internal void WriteToExcel(string excelName, string c1, string c2, string c3, string c4, string c5, string c6, string c7, string c8, string c9, string c10, string c11, Excel.Workbook mybook, Excel.Worksheet mysheet, object Nothing, Excel.Application app) | ||
{ | ||
//open | ||
mysheet.Activate(); | ||
//get activate sheet max row count | ||
int maxrow = mysheet.UsedRange.Rows.Count + 1; | ||
mysheet.Cells[maxrow, 1] = c1; | ||
mysheet.Cells[maxrow, 2] = c2; | ||
mysheet.Cells[maxrow, 3] = c3; | ||
mysheet.Cells[maxrow, 4] = c4; | ||
mysheet.Cells[maxrow, 5] = c5; | ||
mysheet.Cells[maxrow, 6] = c6; | ||
mysheet.Cells[maxrow, 7] = c7; | ||
mysheet.Cells[maxrow, 8] = c8; | ||
mysheet.Cells[maxrow, 9] = c9; | ||
mysheet.Cells[maxrow, 10] = c10; | ||
mysheet.Cells[maxrow, 11] = c11; | ||
mybook.Save(); | ||
mybook.Close(false, Type.Missing, Type.Missing); | ||
mybook = null; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// 有关程序集的一般信息由以下 | ||
// 控制。更改这些特性值可修改 | ||
// 与程序集关联的信息。 | ||
[assembly: AssemblyTitle("Framework发票")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Framework发票")] | ||
[assembly: AssemblyCopyright("Copyright © 2020")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// 将 ComVisible 设置为 false 会使此程序集中的类型 | ||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 | ||
//请将此类型的 ComVisible 特性设置为 true。 | ||
[assembly: ComVisible(false)] | ||
|
||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID | ||
[assembly: Guid("86363aac-22d9-4523-8dc0-a3becbe90c06")] | ||
|
||
// 程序集的版本信息由下列四个值组成: | ||
// | ||
// 主版本 | ||
// 次版本 | ||
// 生成号 | ||
// 修订号 | ||
// | ||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 | ||
//通过使用 "*",如下所示: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |