搜索
bottom↓
回复: 10

上传个自己写的 protel 99 BOM 整理软件

[复制链接]

出0入0汤圆

发表于 2021-9-8 11:15:34 | 显示全部楼层 |阅读模式
小软件一个,整理后所有元器件具有相同封装的都归类到一起

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

阿莫论坛20周年了!感谢大家的支持与爱护!!

曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……

出0入0汤圆

 楼主| 发表于 2021-9-8 11:16:49 | 显示全部楼层
本帖最后由 akin 于 2021-9-8 11:18 编辑

沙发自己留,不喜99的勿喷

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出1325入193汤圆

发表于 2021-9-8 11:20:52 | 显示全部楼层
V1.0吧
整理好了之后 保存操作是?

出0入0汤圆

 楼主| 发表于 2021-9-8 11:24:01 | 显示全部楼层
lb0857 发表于 2021-9-8 11:20
V1.0吧
整理好了之后 保存操作是?

整理完直接保存在原文档,是V1.0,几年前做的了,一直没更新过

出0入59汤圆

发表于 2021-9-8 14:26:24 | 显示全部楼层
AD 直接支持这个功能了, 还能插入EXCEL 表头

出0入0汤圆

发表于 2021-9-9 09:23:46 | 显示全部楼层
为一切 造工具 解决工作问题的人点赞.    还能分享工具的人更是功德无量.

出0入36汤圆

发表于 2021-9-9 09:29:17 来自手机 | 显示全部楼层
放着新的工具不用,非要自己造轮子。

出0入0汤圆

 楼主| 发表于 2021-9-9 09:50:38 | 显示全部楼层
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}

static int                StrBufToIntBuf                (const char *str, int *idx)
{
        int                        n = 0;

        while(*str){
                if((str[0]>='0') && (str[0]<='9')){
                        idx[n++] = atoi(str);
                        while(*str){
                                if(str[0] == ' '){
                                        str++;
                                        break;
                                }
                                else{
                                        str++;
                                }
                        }
                }
                else{
                        str++;
                }
        }
        return n;
}

void InsertSort(int a[], int n)
{
    for(int i= 1; i<n; i++){
        if(a[i] < a[i-1]){               //若第i个元素大于i-1元素,直接插入。小于的话,移动有序表后插入
            int j= i-1;
            int x = a[i];        //复制为哨兵,即存储待排序元素
            a[i] = a[i-1];           //先后移一个元素
            while(x < a[j]){  //查找在有序表的插入位置
                a[j+1] = a[j];
                j--;         //元素后移
            }
            a[j+1] = x;      //插入到正确位置
                }
    }
}

//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
        int                col, row;
        int                ycnt = 0;
        int                d = 0;
        int                r = 0;
        int                Idx[100000];
        char        Str[100000];
        int                Cnt;

        if (OpenDialog1->Execute())
        {
                Edit1->Text=OpenDialog1->FileName;
                Variant vExcelApp, Sheet1, WorkBook1, Range;
                vExcelApp = Variant::CreateObject("Excel.Application");
                //打开文件
                vExcelApp.OlePropertyGet("workbooks").OleFunction("Open", OpenDialog1->FileName.t_str());

                //创建工作薄对象(此时该对象得到的是已打开文件的第一个工作薄)
                WorkBook1 = vExcelApp.OlePropertyGet("ActiveWorkBook");
                //创建工作表对象(此时该对象得到的是已打开文件的第一个工作表)
                Sheet1 = WorkBook1.OlePropertyGet("ActiveSheet");
                col = Sheet1.OlePropertyGet("UsedRange").OlePropertyGet("Columns").OlePropertyGet("Count"); //列数
                row = Sheet1.OlePropertyGet("UsedRange").OlePropertyGet("Rows").OlePropertyGet("Count");    //行数

                StringGrid1->ColCount = col + 1;
                StringGrid1->RowCount = row + 1;
                StringGrid1->Cells[0][0] = "序号";
                for(int y=1; y<StringGrid1->RowCount; y++){
                        char        buf[100];
                        sprintf(buf, "%u", y);
                        StringGrid1->Cells[0][y] = buf;
                }
                for(int x=1; x<StringGrid1->ColCount; x++){
                        for(int y=1; y<StringGrid1->RowCount; y++){
                                String         str = Sheet1.OlePropertyGet("Cells", y, x).OlePropertyGet("Value");
                                StringGrid1->Cells[x][y] = str;
                        }
                }

                if(StringGrid1->ColCount < 4){
                        return;
                }
                for(int y=1; y<StringGrid1->RowCount; y++){
                        if(StringGrid1->Cells[2][y] != ""){
                                for(int n=y+1; n<StringGrid1->RowCount; n++){
                                        if(        (StringGrid1->Cells[1][n] == StringGrid1->Cells[1][y])
                                        &&        (StringGrid1->Cells[3][n] == StringGrid1->Cells[3][y])){
                                                AnsiString s1 = StringGrid1->Cells[2][y];
                                                AnsiString s2 = StringGrid1->Cells[2][n];
                                                s1 += " ";
                                                s1 += s2;
                                                StringGrid1->Cells[2][y] = s1;

                                                StringGrid1->Cells[1][n] = "";
                                                StringGrid1->Cells[2][n] = "";
                                                StringGrid1->Cells[3][n] = "";
                                        }
                                }
                        }
                }
                for(int y=1; y<StringGrid1->RowCount; y++){
                        if(StringGrid1->Cells[1][y] == ""){
                                d = 0;
                                r = y;                                                                                // 记录起始空格行
                                for(int n=y; n<StringGrid1->RowCount; n++){
                                        if(StringGrid1->Cells[1][n] == ""){
                                                d++;                                                          // 统计连续空格行
                                        }
                                        else{
                                                break;
                                        }
                                }
                                for(int i=0; i<(StringGrid1->RowCount-r-d); i++){
                                        StringGrid1->Cells[1][r+i] = StringGrid1->Cells[1][r+i+d];
                                        StringGrid1->Cells[1][r+i+d] = "";
                                        StringGrid1->Cells[2][r+i] = StringGrid1->Cells[2][r+i+d];
                                        StringGrid1->Cells[2][r+i+d] = "";
                                        StringGrid1->Cells[3][r+i] = StringGrid1->Cells[3][r+i+d];
                                        StringGrid1->Cells[3][r+i+d] = "";
                                }
                        }
                }

                StringGrid1->ColCount = 5;
                for(int y=1; y<StringGrid1->RowCount; y++){
                        char        *s = (char *)StringGrid1->Cells[2][y].t_str();
                        char        buf[100];

                        d = 1;
                        while(*s){
                                if(*s == ' '){
                                        d++;
                                }
                                s++;
                        }
                        sprintf(buf, "%d", d);
                        StringGrid1->Cells[4][y] = buf;

                        if(StringGrid1->Cells[1][y] == ""){
                                StringGrid1->RowCount = y;
                                break;
                        }
                }

                for(int x=0; x<StringGrid1->ColCount; x++){
                        for(int y=0; y<StringGrid1->RowCount; y++){
                                Sheet1.OlePropertyGet("Cells", 1+y, 1+x).OlePropertySet("Value", StringGrid1->Cells[x][y].t_str());
                        }
                }
                row = Sheet1.OlePropertyGet("UsedRange").OlePropertyGet("Rows").OlePropertyGet("Count");    //获取行数
                for(int y=StringGrid1->RowCount+1; y<=row; y++){
                        vExcelApp.OlePropertyGet("Rows", StringGrid1->RowCount+1).OleProcedure("Delete");
                }

                // 位号排序
                row = Sheet1.OlePropertyGet("UsedRange").OlePropertyGet("Rows").OlePropertyGet("Count");    //获取行数
                for(int y=2; y<=row; y++){
                        memset(Str, 0, sizeof(Str));
                        strcpy(Str, StringGrid1->Cells[2][y].t_str());
                        Cnt = StringGrid1->Cells[4][y].ToInt();

                        Cnt = StrBufToIntBuf(Str, Idx);
                        if(Cnt >= 2){
                                char        Name[100];
                                char         *ss = Str;
                                int                i=0, j, k=0;

                                InsertSort(Idx, Cnt);

                                while(*ss){
                                        if((ss[0]<'0') || (ss[0]>'9')){
                                                Name[i++] = *ss;
                                        }
                                        else{
                                                Name[i] = '\0';
                                                break;
                                        }
                                        ss++;
                                }

                                memset(Str, 0, sizeof(Str));
                                for(j=0; j<Cnt; j++){
                                        k += sprintf(&Str[k], "%s%d ", Name, Idx[j]);
                                }
                                StringGrid1->Cells[2][y] = Str;
                Sheet1.OlePropertyGet("Cells", 1+y, 3).OlePropertySet("Value", Str);
                        }
                }

                WorkBook1.OleFunction("Save");
                vExcelApp.OleFunction("Quit");
                ShowMessage("整理完成");
        }
}


贴上 BCB 的源代码,其实代码没多少行,方便大家了解BCB如何操作 Excel 文档

出0入927汤圆

发表于 2021-9-9 15:39:58 | 显示全部楼层
不懂就问,什么情况下,需要相同封装的归类到一起。

出0入0汤圆

 楼主| 发表于 2021-9-9 17:27:21 | 显示全部楼层
DoDoTech 发表于 2021-9-9 15:39
不懂就问,什么情况下,需要相同封装的归类到一起。


做BOM表的时候,看来楼上是没做过PCB转生产

出0入927汤圆

发表于 2021-9-9 17:50:31 | 显示全部楼层
akin 发表于 2021-9-9 17:27
做BOM表的时候,看来楼上是没做过PCB转生产

一直做啊,直接导出的BOM和坐标给SMT厂就好了啊。不是同样型号同样封装自动合并了吗?
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-8-16 12:18

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表